Skip to content

CS 1415 - Lab #4

Objective: 

Program with classes

Preparation: 

Review sections 13.1-13.8 from Starting Out with C++ by Gattis.

Programming: 

  1. Name your files LlllFfffLab04.cpp, LlllFfffRational.cpp, and LlllFfffRational.h where Llll is the first four letters of your last name and Ffff is the first four letters of your first name.
  2. Design a Rational class to model rational numbers (fractions). Use integer variables to represent the numerator and the denominator. The class should have a member functions to set the numerator to a new value and a member function to set the denominator to a new value. It should have a member function to reduce the rational number object to lowest terms. There should be a member function to print the rational number object in the form 2/3. All code for the class should be in its own library.
  3. Write a driver program that demonstrates the member functions of the class by having the user input the numerator and denominator for two rational numbers, reducing them, and then displaying them in rational form.
  4. Verify your program works correctly.
  5. Submit your source code file to ude.wons@nosneros.htrag. Due at 8:00 am on 28 January.