Practice with fractions

Problem statement

Write a program to test a student's understanding of arithmetic with rational numbers (fractions). For example:

3/2 + 1/3 is 11/6

5/4 * 2/9 is 5/18

etc.

Procedure

Follow these steps to end up with a sucessful program:

  1. The problem statement is given above.
  2. Write the problem description.
  3. Do the analysis for object design, choosing suitable representations for the class members. Write the object design down.
  4. Do the analysis for process design, adding suitable function members to your classes with appropriate parameters. The application class with have (at least) a function member run. The class for fractional numbers must have (at least) overloaded operators for +, -,*, /, assignment (=) and equality (==).
  5. Write C++ program code from your analysis in 3 and 4.
  6. Create a source file using the editor.
  7. Compile the source code using g++.
  8. The program should present a random problem to the students, read the student's answer and check it against the actual value.
  9. Deliverables:

Notes and hints

       long gcd(long x, long y) {
return (x == 0) ? y : gcd(y % x, x);
}
     #include <ACG.h>
#include <RndInt.h>
...
RandomInteger n(1, 10, new ACG);
...
n() // each "call" produces a different value
Don't worry about seeding the random number generator.