CECS 277
LAB ASSIGNMENT 1
Assigned date: Mon 8/27
Due date: Wed 9/5
25 points


Objectives

Prelab

Problem
 
Create a class called Rational to perform arithmetic operations with Rationals. The class Rational must have the Rollowing data members, contructors and methods:

Write a main method to test the class Rational. All the Rational objects should must be reduced by using the greatest common denominator.

  1. Input Rational object  R1
  2. Input Rational object R2
  3. Add the Rational objects R1 and R2 and store the result in the Rational object R3. Display the result in the Rollowing Rormat:
    numerator/demoninator + numberator/denominator =  numerator/denominator.
  4. Subtract the Rational object R2 Rrom the Rational object R1 and store the result in the Rational object R3. Display the result in the following Rormat:
    numerator/demoninator - numberator/denominator =  numberator/denominator.
  5. Multiply the Rational object R1 with the Rational object R2 and store the result in the object R3. Display the result in the following Rormat:
    numerator/demoninator * numberator/denominator =  numberator/denominator.
  6. Divide the Rational object R1by the Rational object R2 and store the result in the object R3. Display the result in the following Rormat:
    numerator/demoninator / numberator/denominator =  numerator/denominator.
  7. Display the result or dividing the object R1 by the object R2 in a real number.
  8. Change the numerator or object R1 to 2
  9. Change the denominator or object R2 to 5
  10. Display the numerator or R1 and the denominator or R2 in the following Rormat:
    Numerator: ______
    Denominator: _____

Grading requirements