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

  Examine psychoanalytic theory of personality

Examine Psychoanalytic theory of personality

  Describe for a short time motivation for reverse logistics

Describe for a short time motivation for Reverse Logistics

  Effort to exterminate wolves

Before 1918, approximately 55% of the wolves in the New Mexico and Arizona region were male, and 45% were female. However, cattle ranchers in this area have made a determined effort to exterminate wolves.

  Highest poverty rates

The highest poverty rates occur within this group:

  Cooper and shepard experiment

In the Cooper & Shepard experiment (1973), participants were asked to decide whether a stimulus (a letter) was normal (simply rotated in the picture plane) or backwards (flipped to its mirror image before the rotation).

  Survey on effects of globalization

Brainstorm questions and create a 5- to 10-question survey to administer to team members' coworkers or adult acquaintances.

  Explain trategic thinker-tactical planner or logistician

By orientation to cooperative work in mission-driven organization like armed forces, do you think yourself to be strategic thinker, tactical planner, or logistician?

  Deduction and improving attention

How would everyday activities be impacted by reduction in attention e.g. the activities which are particularly easy to attend to versus those which are more difficult?

  Decision making in today business environment

Write a 350- to 700-word review of the article. Your review should discuss how the SOX Act may affect ethical decision making in today's business environment, and the criminal penalties for which the act provides.

  Separate personality and limited liability

Courts often say they will ignore the separate corporate entity where the business has sold something to another person on credit and it is now claimed that the separate personality of the corporation and it's perpetual existence means there is li..

  Regarding the sexual harassment

Is this a case of sexual harassment? If so, what type? What might the legal penalties be? What should Betty do?

  Breach of patient confidentiality

As an employee of hospital one day you noticed two nurses laughing as they were reading something off of computer screen. You inquired as to what they were laughing at and they proceeded to show you what they were reading.

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