Question: C++: You will program a calculator The fractions will both read as strings, eg. 2/7 but they are Managed Strings and not C++ strings. We

C++:

You will program a calculator

The fractions will both read as strings, eg. 2/7 but they are Managed Strings and not C++ strings. We will have to convert them using a Utility Function. They will be set into the class as two C++ strings and a char. You will parse the strings in the class to get the integers for the fractions.

Your FracCalc class will have two constructors, one (default) constructor and an overloaded constructor, which passes the two fractions and the operation. The overloaded constructor will be implemented with a constructor initializer. The default constructor will delegate to the Overloaded constructor. Since the overloaded constructor will have all of the data necessary, it will call the Calculate method.

You will also have two public methods,GetData, which will pass the two fraction strings and the operation, andGetResults, which will return a string describing the problem and the answers. The decimal format should be set to 2 decimal places.

You will have three private methods,Calc,ReduceFracandParseFrac. TheCalcmethod will call theParseFracmethod to parse the strings, perform the calculations, and then call theReduceFracmethod. Use Euclids algorithm to get the greatest common denominator to reduce the fractions.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!