Homework

Homework Questions? Ask a Tutor for Answers ASAP

Connect one-on-one with {0} who will answer your question

calculations. You need define a...

Write an interactive program that performs fractional calculations. You need define a class CFrac for a fractional number according to the UML diagram below:

CFrac

- numerator : int

- denominator : int

- simplify () : void

+ CFrac (int = 0, int = 1)

+ ~CFrac()

+ add (const CFrac&) const : CFrac

+ subtract (const CFrac&) const : CFrac

+ multiply (const CFrac&) const : CFrac

+ divide (const CFrac&) const : CFrac

+ showFrac () const : void

+ setFrac () : void

Where the arithmetic functions perform the corresponding arithmetic calculations on the current object and the parameter object, and return the result. The subtract function should subtract the parameter object from the current object, and return the difference. Likewise, the divide function should divide the current object by the parameter object and return the quotient. The parameter is passed as constant reference so it is efficient and the parameters can’t be modified. All these four arithmetic functions are constant functions because they do not modify the current object.

The two argument constructor also serves as default constructor. The setFrac function prompts and gets user input of numerator and denominator of a fraction.

The simplify function reduces the fraction to least term; it does not care if the numerator is greater than the denominator. It is private so it’s only called by other member functions. The showFrac function is responsible for displaying the fraction properly. If the numerator is greater than denominator, then it displays a whole number followed by a fraction. For example, a fractional number of 2/8 should be reduced to ¼, and 9/6 should be reduced to 3/2, and 3/2 should be displayed as 1 ½.

Here are some more examples:

5/2 should be displayed as 2 1/2

4/4 should be displayed as 1

0/8 should be displayed as 0

4/12 should be displayed as 1/3

Now that you have an ADT for a fractional number, you will use it for the fractional calculation program. The program should first display a menu to let user choose what kind of calculation to perform:

Fraction Calculation Menu:

1 -- ADDITION

2 -- SUBTRACTION

3 -- MULTIPLICATION

4 -- DIVISION

5 -- EXIT

-- >

As long as user does not choose 5, the program prompts for two fractional numbers, perform the selected calculation on these two numbers, and display the result.

When one calculation is finished, the menu is displayed again. Unless user chooses 5, the program shall keep on running. Display the menu and get user choice should be done in a function.

CFrac

- numerator : int

- denominator : int

- simplify () : void

+ CFrac (int = 0, int = 1)

+ ~CFrac()

+ add (const CFrac&) const : CFrac

+ subtract (const CFrac&) const : CFrac

+ multiply (const CFrac&) const : CFrac

+ divide (const CFrac&) const : CFrac

+ showFrac () const : void

+ setFrac () : void

Where the arithmetic functions perform the corresponding arithmetic calculations on the current object and the parameter object, and return the result. The subtract function should subtract the parameter object from the current object, and return the difference. Likewise, the divide function should divide the current object by the parameter object and return the quotient. The parameter is passed as constant reference so it is efficient and the parameters can’t be modified. All these four arithmetic functions are constant functions because they do not modify the current object.

The two argument constructor also serves as default constructor. The setFrac function prompts and gets user input of numerator and denominator of a fraction.

The simplify function reduces the fraction to least term; it does not care if the numerator is greater than the denominator. It is private so it’s only called by other member functions. The showFrac function is responsible for displaying the fraction properly. If the numerator is greater than denominator, then it displays a whole number followed by a fraction. For example, a fractional number of 2/8 should be reduced to ¼, and 9/6 should be reduced to 3/2, and 3/2 should be displayed as 1 ½.

Here are some more examples:

5/2 should be displayed as 2 1/2

4/4 should be displayed as 1

0/8 should be displayed as 0

4/12 should be displayed as 1/3

Now that you have an ADT for a fractional number, you will use it for the fractional calculation program. The program should first display a menu to let user choose what kind of calculation to perform:

Fraction Calculation Menu:

1 -- ADDITION

2 -- SUBTRACTION

3 -- MULTIPLICATION

4 -- DIVISION

5 -- EXIT

-- >

As long as user does not choose 5, the program prompts for two fractional numbers, perform the selected calculation on these two numbers, and display the result.

When one calculation is finished, the menu is displayed again. Unless user chooses 5, the program shall keep on running. Display the menu and get user choice should be done in a function.

Show More

Show Less

Was this answer helpful?

Describe your issueThe assistant will guide you

Chat 1:1 with a tutorLicensed Experts are available 24/7

100% satisfaction guaranteeGet all the answers you need

Related Homework Questions

Can you rewrite this code to stdio.h please. FOR LOGIC PRO

Hi good day can you rewrite this code to stdio.h please. FOR LOGIC PRO/* Author Name: Creation Date: Description: Program to evaluate 2D array. */#includeusing namespace std;//constants for number of … read more

For LogicPro only.... Java homework program. Jagged Array

For LogicPro only.... Java homework program.Jagged Array Your task for this problem is to read in a jagged array of integers from user input. First ask for the number of rows. Then ask for each row as… read more

For this assignment you will be building on the Fraction

For this assignment you will be building on the Fraction class you began last week. You'll be making five major changes to the class.Delete your set() function. Add two constructors, a default constru… read more

Write a program to model a simple calculator. Each data line

Write a program to model a simple calculator. Each data line should consist of the next operation to be performed from the list below and the right operand. Assume the left operand is the accumulator … read more

create a text-based, menu-driven program that allows the user to choose whether to add, su

create a text-based, menu-driven program that allows the user to choose whether to add, subtract, multiply or divide two numbers. The program should then input two double values from the use, perform … read more

Write a fraction class whose objects will represent fractions.

Write a fraction class whose objects will represent fractions. You should provide the following member functions: Two constructors, a default constructor which assigns the value 0 to the fraction, and… read more

I need to baseball Calculator that: Write a menu-driven program

I need to baseball Calculator that: Write a menu-driven program implementing a calculator to compute each of these stats. The program should start by displaying a menu similar to this: Baseball Calcul… read more

for logicpro only Create a class called Rational for performing

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 class—the numerator and the deno… read more

Prefer LogicPro Only: Write a Fraction class that overloads

Prefer LogicPro: Write a Fraction class that overloads the arithmetic operators (+, -, *, /). Minimally, your fraction class should include the following methods that behave as directed: Fraction() Th… read more

Drink Machine SimulatorWrite a program that simulates a

Drink Machine Simulator Write a program that simulates a soft drink machine. The program should use a structure that stores the following data: Drink Name, Drink Cost and Number of drinks in Machine T… read more

create a Fraction class with fields that hold a whole number,

create a Fraction class with fields that hold a whole number, a numerator, and a denominator. In addition: Create properties for each field. The set accessor for the denominator should not allow a 0 v… read more

Hello, I have this weeks question. Please mark the code up

Hello, I have this week's question. Please mark the code up with notes, considerably. I must understand this code the best I can and the more notes you put in the better it is for me. Thanks. Create a… read more

*For LogicPro Only**This week, you need to create a Fraction

*For LogicPro Only** This week, you need to create a Fraction class with fields that hold a whole number, a numerator, and a denominator. **In addition: Create properties for each field. The set acces… read more

1. Girl Scout Program Create a class named Girl Scout that

1. Girl Scout Program Create a class named Girl Scout that contains fields for a Girl Scout's name, troop number, and dues owed. The program should justify the following conditions: • Include a consta… read more

This question is for Altprog can you help me with the following

This question is for Altprog can you help me with the following program Can you help me with the following program I will be creating a Height class and a small program to test that class. The Height … read more

here is what is missing 1.There is no extPersonType class.

here is what is missing 1.There is no extPersonType class. 2.AddresType class does not use the personType class. 3.No main method. 4.Addressbook does not contain scope for 500 entries. 5.None of the f… read more

there is no function decimalToRoman 2. No overloading of

there is no function decimalToRoman 2. No overloading of insertion and extraction operator. 3. No derived class extRomanType 4. No overloaded arithmetic operators for derived class 20. In Programming … read more

I want to see how this is done. It is already past due

Objective: At the completion of this project, you will have created an application that • Defines a class to represent complex numbers, • Use a constructor to initialize a Complex Number object • pass… read more

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.

Ask-a-doc Web sites: If you've got a quick question, you can try to get an answer from sites that say they have various specialists on hand to give quick answers... Justanswer.com.

JustAnswer.com...has seen a spike since October in legal questions from readers about layoffs, unemployment and severance.

Web sites like justanswer.com/legal

...leave nothing to chance.

...leave nothing to chance.

Traffic on JustAnswer rose 14 percent...and had nearly 400,000 page views in 30 days...inquiries related to stress, high blood pressure, drinking and heart pain jumped 33 percent.

Tory Johnson, GMA Workplace Contributor, discusses work-from-home jobs, such as JustAnswer in which verified Experts answer people’s questions.

I will tell you that...the things you have to go through to be an Expert are quite rigorous.

Wonderful service, prompt, efficient, and accurate. Couldn't have asked for more. I cannot thank you enough for your help.

Freshfield, Liverpool, UK

This expert is wonderful. They truly know what they are talking about, and they actually care about you. They really helped put my nerves at ease. Thank you so much!!!!

Los Angeles, CA

Thank you for all your help. It is nice to know that this service is here for people like myself, who need answers fast and are not sure who to consult.

Hesperia, CA

I couldn't be more satisfied! This is the site I will always come to when I need a second opinion.

Kernersville, NC

Just let me say that this encounter has been entirely professional and most helpful. I liked that I could ask additional questions and get answered in a very short turn around.

Woodstock, NY

Thank you so much for taking your time and knowledge to support my concerns. Not only did you answer my questions, you even took it a step further with replying with more pertinent information I needed to know.

Elkton, Maryland

He answered my question promptly and gave me accurate, detailed information. If all of your experts are half as good, you have a great thing going here.

Dallas, TX

< Previous | Next >

LogicPro

Engineer

24,282 satisfied customers

Expert in Python,Java C++ C C# VB Javascript Design SQL HTML

Manal Elkhoshkhany

Tutor

4,720 satisfied customers

More than 5000 online tutoring sessions.

Linda_us

Finance, Accounts & Homework Tutor

3,138 satisfied customers

Post Graduate Diploma in Management (MBA)

Chris M.

M.S.W. Social Work

2,850 satisfied customers

Master's Degree, strong math and writing skills, experience in one-on-one tutoring (college English)

F. Naz

Chartered Accountant

2,270 satisfied customers

Experience with chartered accountancy

Bizhelp

CPA

1,887 satisfied customers

Bachelors Degree and CPA with Accounting work experience

Jabi

Tutor

1,795 satisfied customers

I've been an Expert on JustAnswer since July 2010.

< Previous | Next >

Disclaimer: Information in questions, answers, and other posts on this site ("Posts") comes from individual users, not JustAnswer; JustAnswer is not responsible for Posts. Posts are for general information, are not intended to substitute for informed professional advice (medical, legal, veterinary, financial, etc.), or to establish a professional-client relationship. The site and services are provided "as is" with no warranty or representations by JustAnswer regarding the qualifications of Experts. To see what credentials have been verified by a third-party service, please click on the "Verified" symbol in some Experts' profiles. JustAnswer is not intended or designed for EMERGENCY questions which should be directed immediately by telephone or in-person to qualified professionals.