| Object Oriented Programming and Design with C++ | Dr. Aaron Naiman |
| Course #15001301 | <naiman@math.jct.ac.il> |
| Spring, 2006 | Office hours: Monday, 13:30-14:30 |
Define the following functions for non-class, non-struct angles. Have
your angles be comprised of degrees, minutes (1/60 degree) and seconds
(1/60 minute). The first two should be ints, and the
last, a float (or double). Take care that
the angle is always stored between 0° and 360°, and the
minutes and seconds between 0 and 60 (non-inclusive). Have the parts
of each angle be separate variables, i.e., not elements of an array.
Note that aside from reporting errors, the only output occurs in the input (for instructions) and output functions.
Have your main() supply the user with a menu (iterating
until s/he decides to quit), for performing the functions above. In
addition, allow the user to allocate an array of such things, and then
the user specifies, e.g., to perform an operation on the second and
sixth elements, and place the answer in the ninth. Alternatively, the
user can specify to read in/write out the array of information from/to
a file (get the file name from the user!).
Note however, that the functions listed above, work on
individual (1, 2 or 3) angles, and know nothing of your
array. On the other hand, the switch you will have in
main() will work with your array.
To assist you in getting information from the user, have a separate little library consisting of at least the following two functions:
static) function template which
receives a question (as a constant string) to prompt the
user, as well as a variable into which to place the input
value