Question: Lab8 Lab ex ercise Computing III - 8 We will design a class called Rational for representing rational numbers. A rational numbcr can be expressed

Lab8Lab8 Lab ex ercise Computing III - 8 We will design a

Lab ex ercise Computing III - 8 We will design a class called Rational for representing rational numbers. A rational numbcr can be expressed in the form of p/q where p and q are integers and q is not 0. For example, 1/3, 3/5, 4/16 are all rational numbers. However, 4/16 after normalizing becomes 1/4. Note that we mean 1/2 as a fraction, and not integer division Your Rational class should include the following: -a default constructor that initializes an object to 0 (that is, O/1) - a single parameter constructor (int), parameter named wholeNumber and define the constructor, so the object will be initialized to wholeNumber/1 - a 2 parameter constructor that sets the numerator and denominator integers (denominator cannot be 0) overloaded input >> and output , +,-, *, / (Two rational numbers a/b and c/d are equal if a*d-c*b. fb and d are positive rational numbers, a/b is less than c/d if a*d is less than c*b.) - a function to normalize the rational number so that after normalization, the denominator is positive, and the numerator and denominator are as small as possible. So, after normalization, 4/-16--1/4 Run the following test: Enter the numerator and denominator of the first rational number (X): 1 2 Enter the numerator and denominator of the second rational number: -8-10 4/5 X- Y: 1/2- 4/5-3/10 X * Y: 1 /2 * 4/5-2/5 X/Y:1/2/4/5 = 5/8

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!