Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I need help in my c++ hw. The client program shouldn't be chaned. Thank you!!!! For this assignment you will be building on the fraction

image text in transcribed
image text in transcribedI need help in my c++ hw. The client program shouldn't be chaned. Thank you!!!!
For this assignment you will be building on the fraction class you began last week. You'll be making four major changes to the class. . [15 points] Delete your set() function. Add two constructor a default constructor that assigns the value 0 to the fraction, and a constructor that takes two parameters. The firs parameter will represent the initial numerator of the fraction, and the second parameter will represent the initial denominator of the fraction. Since fractions cannot have denominators of 0, the default constructor should assign 0 to the numerator and 1 to the denominator 2. [15 points] Add the const keyword to your class wherever appropriate. Your class may still work correctly even if you don't do this correctly, so this will require extra care!! points] Add a private "simplify)" function to your class and it from the appropriate member functions. (There will probably be 5 places where you need to call it.) The best way to do this is to make the function a void function with no parameters that reduces the calling object As you can see from the sample output given below, you are still not required to change improper fractions into mixed numbers for printing. Just print it as an improper fraction. Make sure that your class will reduce ANY fraction, not just the fractions that are tested in the provided client program. Fractions should not be simply reduced upon output, they should be stored in reduced form at all times. In other words, you should ensure that all fraction objects are reduced before the end of any member function. You are also not required to deal with negative numbers, either in the numerator or the denominator You must create your own algorithm for reducing fractions Don't look up an already existing algorithm for reducing fractions or finding GCFThe point here is to have you practice solving the problem on your own. In particular, don't use Euclid's algorithm. Don't worry about being efficient. It's fine to ave your function check every possible factor, even if it would be more efficient to just check prime numbers. Just create something of your own that works correctly on ANY fraction. Note: this part of the assignment is worth 5 points. If you are having trouble keeping up with the class, I suggest you skip this part and take the 5 point deduction 4. [10 points] Put the client program in a separate file from the 4 [10 points] Put the client program in class, and divide the class into specification file (fraction.h) and implementation file (fraction.cpp), so your code will be in 3 separate files. ur class should still have exactly two data members. I am providing a client program for you below. You should copy and paste this and use it as your client program. The output that should produced when the provided client program is run with your class is also given below, so that you can check your results. Since you are not writing the client program, you are not required to include comments in it

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

Database Design Query Formulation And Administration Using Oracle And PostgreSQL

Authors: Michael Mannino

8th Edition

1948426951, 978-1948426954

More Books

Students also viewed these Databases questions

Question

Solve each equation. Check the solutions. 2x = 11x + 3

Answered: 1 week ago

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago