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
lanaguage C++

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

Beyond Big Data Using Social MDM To Drive Deep Customer Insight

Authors: Martin Oberhofer, Eberhard Hechler

1st Edition

0133509796, 9780133509793

More Books

Students also viewed these Databases questions