Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Spatial Database Systems Design Implementation And Project Management

Authors: Albert K.W. Yeung, G. Brent Hall

1st Edition

1402053932, 978-1402053931

More Books

Students also viewed these Databases questions

Question

How would you handle this situation?

Answered: 1 week ago