In c++ 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.
In c++ 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.
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 8 images