Starting from:

$30

 Rational Numbers Program Requirements

Rational Numbers Program Requirements
*Adapted from Deitel & Deitel (1994)
Task
Using Microsoft Visual Studio, write a program that includes a class called Rational for
performing arithmetic on fractions. The Rational constructor should store a numerator and a
denominator. The class should contain the following public member functions:
 void Rational::add(int n, int d) – Adds a fraction to the current fraction
 void Rational::sub(int n, int d) – Subtracts a fraction from the current
fraction
 void Rational::mul(int n, int d) – Multiplies the current fraction by a new
fraction
 void Rational::div(int n, int d) – Divides the current fraction by a new
fraction
The results of all arithmetic operations overwrite the previous values. Fractions should always
be represented in reduced form.
The main() function should ask for an initial numerator and denominator, then enter a menudriven loop where the various arithmetic operations can be performed. Use a try/catch block to
check for illegal menu selections.
Submit a .zip file to Canvas that contains three files: main.cpp, rational.cpp, and rational.h.
Examples

More products