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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started