Question
Problem A: No Minutes (20 points) In this part you work only with degrees and direction, and not minutes. Specifically, write a C++ program that
Problem A: No Minutes
(20 points)
In this part you work only with degrees and direction, and not minutes.
Specifically, write a C++ program that asks a user to input an original longitude, plus a
change in longitude. The original longitude should be in terms of degrees (but not minutes)
and whether the direction is E or W. The change should just be a nonnegative number,
that you can assume is in the same direction as the original longitude. The program should
then calculate and output the new longitude, using the input/output format shown in the
following example:
Original longitude degrees and direction: 172 W
Longitude change degrees: 10
178 degrees E
Here are some further clarifications, notes, and hints:
You may assume the original longitude input is a valid longitude. That is, you do
not need to check that the original values input are in the valid ranges. And you may
assume, without checking, that the change degrees are nonnegative.
2
However, do not make any further assumptions on the value of the change degrees.
For example, a value of 720 is allowed (and corresponds to going around the world
twice).
The output longitude should always be between 0 degrees and 180 degrees, inclusive,
regardless of whether the direction is east or west.
Note that for 0 degrees, the direction is unnecessary. The same holds true for 180
degrees. So in inputting these as the original longitude or a change in longitude, the
user may enter either direction. However, if your programs outputs either of these it
should write them without the direction, for example just
180 degrees
.
Follow the input and output formats shown in the example above.
C++ hint: you will likely find the remainder operator % useful.
Start this problem soon. This Problem A program should not be difficult, but is not
trivial either. Moreover, Problem B builds on Problem A. So you will need to give
yourself enough time not only to get your Problem A code working correctly, but also
to complete the more difficult Problem B
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started