Professional Documents
Culture Documents
Rational Numbers Practice
Rational Numbers Practice
Rational Numbers Practice
3. Attributes of class
- int numerator, int denominator
4. Behaviour of class
- public void add(Rational r2) --> should add r2 to r1
- public void subtract(Rational r2) --> should subtract r2 fromr1
- public void print() --> should print in the format "a/b"
5. Main function
- create 2 objects: one with default constructor and one with
the Rational(r1, r2) constructor
- call r1.add(r2) and print the new value of r1
- call r1.subtract(r2) and print the new value of r1