Question: Lab exercise Computing III 8 We will design a class called Rational for representing rational numbers. A rational number can be expressed in the form

 Lab exercise Computing III 8 We will design a class called

Lab exercise Computing III 8 We will design a class called Rational for representing rational numbers. A rational number 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, -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. If b and d are positive rational numbers, a/b is less than c/d if ad 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): 12 Enter the numerator and denominator of the second rational number: -8-10 Y-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 Is Y>X or X> Y? 4/5> 1/2

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!