ryan449
October 7th, 2009, 03:40 PM
Hello, I am in first year computer science at university... i have an assignment that has one question on it that i cant get my head around and was hoping someone could help me out with it...im sure its very simple...
Precise angle measurements (and geographical coordinates) are often
expressed in the DMS format showing degrees, minutes and seconds (for
example, 234˚1217). There are 360 degrees in a circle, there are 60
minutes in one degree and 60 seconds in one minute. Write a program
that inputs angle measurements for two angles (each measurement
requires you to input 3 values) and then adds the two angles together and
prints out the resulting angle. For example,
234˚1217 + 10˚1010 = 244˚2227 (correction in yellow)
Notice that if the sum of the two seconds components exceeds 60 it
wraps around (like a clock) but also causes a carry into the minutes of
the result. For example,
10˚2040 + 10˚2040 = 20˚4120
This wrap around and carry can occur for minutes too (causing a carry into
degrees). The wrap around can also happen for degrees but theres no
carry in this case. Consider this example:
200˚3040 + 159˚2920 = 0˚00
HINT: The integer division and remainder operators are key here. Use
temporary variables to capture each of the carry values. If you have programmed before, please resist the temptation to use an if statement -
its not needed.
Thanks.
Precise angle measurements (and geographical coordinates) are often
expressed in the DMS format showing degrees, minutes and seconds (for
example, 234˚1217). There are 360 degrees in a circle, there are 60
minutes in one degree and 60 seconds in one minute. Write a program
that inputs angle measurements for two angles (each measurement
requires you to input 3 values) and then adds the two angles together and
prints out the resulting angle. For example,
234˚1217 + 10˚1010 = 244˚2227 (correction in yellow)
Notice that if the sum of the two seconds components exceeds 60 it
wraps around (like a clock) but also causes a carry into the minutes of
the result. For example,
10˚2040 + 10˚2040 = 20˚4120
This wrap around and carry can occur for minutes too (causing a carry into
degrees). The wrap around can also happen for degrees but theres no
carry in this case. Consider this example:
200˚3040 + 159˚2920 = 0˚00
HINT: The integer division and remainder operators are key here. Use
temporary variables to capture each of the carry values. If you have programmed before, please resist the temptation to use an if statement -
its not needed.
Thanks.