Question
Problem: A rational number is a quotient of two integers such as 4/7 and 5/9. We consider a number to be in a reduced form
Problem: A rational number is a quotient of two integers such as 4/7 and 5/9. We consider a number to be in a reduced form if the rational number denominator and numerator have no gcd greater than 1. For example the reduced form for 4/6 is 2/3. The following code provides a skeleton code implementation to this problem. The Rational class has a constructor Rational(int, int) that takes two integers and stores two values in reduced form in corresponding private numbers. The class has an overloaded insertion operator << that is used for output of objects of the class.
Your need to: - Read and understand the skeleton code. - Modify the class Rational to add overloaded operators +, -, *, / to be used for addition, subtraction, multiplication and division. - For simplicity, assume the numbers and the arithmetic operators are separated by whitespaces such as 2 / 5 1 / 7
In C++
//Rational Arithmetic I #include
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