Question: Define a class called Rational that would be used to store rational numbers. Include a constructor with two arguments that would initialize the numerator and

Define a class called Rational that would be used to store rational numbers. Include a constructor with two arguments that would initialize the numerator and denominator to the values of its respective arguments; include a default constructor that would initialize the rational to 0/1. Overload the operators =, +=, -=, *=, /=, and then using these operators overload the following operators: +, -, *, /. Also overload the comparison operators <, >, ==, !=, <=, >= and the i/o stream operators >> and <<. Write a test program that would prompt the user to input two rational numbers in the form A/B and print out their sum, difference, product, and quotient, as well as the truth table of comparison tests. Note: let any sign be carried out by the numerator; i.e., keep the denominator positive.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!