CECS 277
LAB ASSIGNMENT #1
Assigned date: Wed 1/20
Due date: Wed 1/27
10 points


Objectives

Prelab

Problem

Create a class called Fraction for performing arithmetic operations with fractions. The class Fraction must have the following data members, contructors and methods:

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

  1. Input Fraction object  F1
  2. Input Fraction object F2
  3. Add the Fraction objects F1 and F2 and store the result in the Fraction object F3. Display the result in the following format:
    numerator/demoninator + numberator/denominator =  numberator/denominator.
  4. Subtract the Fraction object F2 from the Fraction object F1 and store the result in the Fraction object F3. Display the result in the following format:
    numerator/demoninator - numberator/denominator =  numberator/denominator.
  5. Multiply the Fraction object F1 with the Fraction 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 Fraction object F1by the Fraction object F2 and store the result in the object F3. Display the result in the following format:
    numerator/demoninator / numberator/denominator =  numberator/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