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

  Illustrate what are subfields of anthropology

Illustrate what are subfields of anthropology. Illustrate what is scientific method. Illustrate what is an anthropologist's primary ethical obligation.

  Safeguard against a corrupt or bloated bureaucracy

Suggest at least two electoral or constitutional means by which an informed citizenry could safeguard against a corrupt or bloated bureaucracy.

  Utilitarian theory-abortion-capital punishment

What do you think utilitarian theory tells us about the morality of such questions as abortion, capital punishment, or euthenasia? Make answer brief.

  How the role of social worker is significant for society

The role of social worker is very significant for society as whole. Can managers act as social workers? Explain why or Why not?, How can managers contribute to social and political context?

  Explains the key leadership idea

Start with an Introduction to your paper that includes the name of the article, author and source and explains the key leadership idea or ideas that this article covers.

  Script of conversation between two people-a dialogue

You will create a script of a conversation between two people—a dialogue. This will be like writing a scene for a movie or television show. Have fun! Use characters from your favorite movies, television shows, and books if you like. You may also simp..

  The flow rate of cyclo-hexane produced from this process

The flow rate of cyclo-hexane produced from this process (MEB).  The fraction of liquid and vapor for the overhead and bottom product of the distillation column (MEB/TKK).  Amount of hydrogen recycled (MEB).

  Someone who is not a party to lawsuit

Someone who is not a party to a lawsuit but has an interest in the outcome and therefore wants to become a party to the suit must:

  Chain of custody in criminal investigations

Chain of custody in criminal investigations is a vital aspect of criminal investigations. Patrol officers are the first responders to a murder scene based on 911 calls.

  Social order and progress with capitalism

John Maynard Keynes, writing in the midst of the Great Depression of the 1930s, argued for stabilization policies in order to maintain social order and progress with capitalism.

  Psychological research-aspects of social life

This posting explains how psychological research applies to various aspects of social life. It also answers the following items:

  Performance evaluation and review technique

Compose the tasks that would be needed to complete a Gantt chart (project schedule) for outsourcing the company's payroll system. Compare the advantages and disadvantages of using a Gantt chart versus using the Performance evaluation and review techn..

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