Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

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

Graph Databases New Opportunities For Connected Data

Authors: Ian Robinson, Jim Webber, Emil Eifrem

2nd Edition

1491930896, 978-1491930892

More Books

Students also viewed these Databases questions

Question

2. Whats involved in listening?

Answered: 1 week ago

Question

What does stickiest refer to in regard to social media

Answered: 1 week ago

Question

1. Diagnose and solve a transfer of training problem.

Answered: 1 week ago