Rational for performing arithmetic with fractions

Assignment Help Other Subject
Reference no: EM13201916

Create a class called Rational for performing arithmetic with fractions. Write a program to test your class.
Use integer variables to represent the private data of the classthe numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared. The constructor should contain default values in case no initializers are provided and should store the fraction in reduced form. For example, the fraction would be stored in the object as 1 in the numerator and 2 in the denominator.
Provide public member functions that perform each of the following tasks:
a. Adding two Rational numbers. The result should be stored in reduced form.
b. Subtracting two Rational numbers. The result should be stored in reduced form.
c. Multiplying two Rational numbers. The result should be stored in reduced form.
d. Dividing two Rational numbers. The result should be stored in reduced form.
e. Printing Rational numbers in the form a/b, where a is the numerator and b is the denominator.
f. Printing Rational numbers in floating-point format.

Reference no: EM13201916

Questions Cloud

What is bill andersons monthly payment to payoff the loan : initially he makes a down payment of $6,000 on a $15,000 car. The balance is paid in 24 equal monthly payments with annual interest at 12%. When he has made the last payment on the loan, he trades in the 2-year old car for $6,000 on a new $15,000 ..
Promote or compromise food safety : There has been several complaints in your community about dirty restaurants. Several restaurants are no longer in business as a result of a television expose. You are the head of a citizen task force and have been asked to make recommendations for im..
How to find which plan is more economical : The town of Dry Gulch needs more water from Pine Creek. The town engineer has selected two plans for comparison: a gravity plan (divert water at a point 10 miles up Pine Creek and pipe it by gravity to the town) and a pumping plan (divert water at..
Namely deforestation and soil degradation : In which of the following countries have people suffered the most from massive crop failures due to environmental mismanagement, namely deforestation and soil degradation?
Rational for performing arithmetic with fractions : Use integer variables to represent the private data of the classthe numerator and the denominator. Provide a constructor that enables an object of this class to be initialized when it is declared.
Socio- economic and political organization of the society : What do monumental architecture imply about the socio- economic and political organization of the society that created it?
What''s the unusual spelling pattern : What's the unusual spelling pattern?
Calculate to the nearest cent : Calculate to the nearest cent, the final amount of money for an investment of 6,000 dollars at an APR of 2.9% compounded 4 times a year after 9 years. (Penny round your answer and please enter your answer without the $ sign.)
Find r and theta so that the perimeter is smallest : A circular sector with radius r and angle theta has an area . Find r and theta so that the perimeter is smallest when A=2 and A=10.

Reviews

Write a Review

Other Subject Questions & Answers

  Flexible manufacturing and lean manufacturing

How do flexible manufacturing and lean manufacturing differ from other manufacturing technologies? Why are these new approaches needed in today's environment? 250 words or more and references. Please use proper grammer so that one can understand the ..

  Influence of drugs over nervous system

How do drugs influence the nervous system? How are the neurological processes altered due to the presence of drugs? Please reply.

  Objectives in practicum learning agreement

I am to prepare a 1400-1750 words summative evaluation that analyses evaluates and summarizes my practicum experiences and the achievement of my personal objectives in my practicum learning agreement.

  Biological basis of sleep and dreams

What is the biological basis of sleep and dreams? Where do dreams occur in the cycle of sleep, and why are they important to our psychological well-being?

  Korean war and the vietnam war

Two of the proxy wars that are the most famous and significant are the Korean War and the Vietnam War (though neither was truly a "war," since war was never officially declared in either instance).

  What cost cutting measures are proposed

For purposes of our discussion, either discuss recent federal legislation passed via The Affordable Care Act or discuss cost cutting measures to Medicare/ Medicaid proposed by the state in which you reside.

  Labor negotiations-work slowdowns or stoppages

Many times labor negotiations are very contentious, especially when the parties have had an adversarial relationship, as evidenced by a number of unresolved grievances, work slowdowns or stoppages, deteriorating economic conditions, etc.

  Modal logic

Modal Logic: Give a B-model that makes this sentence true in World 1, and an S4 model that makes that same sentence false in World 1:  ?◊P → (P v ~◊Q)

  Gross income for the current taxable year

How much does Jane include in her gross income for the current taxable year with respect to the distribution to her?

  Describe evolution of beatles musicwith examples

Describe evolution of beatles musicwith examples from early middle later period. analyze musical elements that created the change in their sound.

  Explain international organisation of securities commission

Write short notes on the following: (a) International Organisation of Securities Commission (IOSCO) (b) International Association of Insurance Supervisors (IAIS)

  Find rate at which speed of light equal transmission delay

Consider MAN with average source and destination 20km apart. At what data rate does round trip delay due to speed of light equal transmission delay for 1 kB packet?

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd