CECS 277
LAB ASSIGNMENT #1
Assigned date:Wed 1/25
Due date: Wed 2/1
12 points


Objectives

Prelab

Problem

Create a class called Rational for performing arithmetic operations with Rationals. The class Rational must have the following 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  F1
  2. Input Rational object F2
  3. Add the Rational objects F1 and F2 and store the result in the Rational object F3. Display the result in the following format:
    numerator/demoninator + numberator/denominator =  numberator/denominator.
  4. Subtract the Rational object F2 from the Rational object F1 and store the result in the Rational object F3. Display the result in the following format:
    numerator/demoninator - numberator/denominator =  numberator/denominator.
  5. Multiply the Rational object F1 with the Rational object F2 and store the result in the object F3. Display the result in the following format:
    numerator/demoninator * numberator/denominator =  numberator/denominator.
  6. Divide the Rational object F1by the Rational object F2 and store the result in the object F3. Display the result in the following format:
    numerator/demoninator / numberator/denominator =  numerator/denominator.
  7. Display the result of dividing the object F1 by the object F2 in a real number.
  8. Change the numerator of object F1 to 2
  9. Change the denominator of object F2 to 5
  10. Display the numerator of F1 and the denominator of F2 in the following format:
    Numerator: ______
    Denominator: _____

Grading requirements