Question: Write a program that implements a four-function (+, , *, /) calculator for fractions. The program should prompt for and read the first fraction, an

Write a program that implements a four-function (+, , *, /) calculator for fractions. The program should prompt for and read the first fraction, an arithmetic operator, and a second fraction, perform the required calculation, display the result, and then ask if the user wants to continue. The result should be displayed as a fraction - it does not need to be in reduced form.

Program requirements:

  1. Write a program that does not make use of any floating point data nor variables. Read the numerator and denominator of each fraction into separate integer variables (using the same technique given in the first problem). Then produce the numerator and denominator of the resulting fraction using basic fraction arithmetic. For example, a/b + c/d = (ad+bc)/bd.

  2. Make use of a switch statement to organize the calculations associated with the different arithmetic operations.

  3. Use a do loop to control the calculator repetition.

Here is an example of a users interaction with the program:

Enter first fraction: 1/2

Enter operation: +

Enter second fraction: 1/3

Sum = 5/6

Continue (y or n)? y

Enter first fraction: 1/2

Enter operation: -

Enter second fraction: 1/3

Difference = 1/6

Continue (y or n)? y

Enter first fraction: 1/2

Enter operation: /

Enter second fraction: 1/3

Quotient = 3/2

Continue (y or n)? n

--------------------------------

Process exited after 56.37 seconds with return value 0

Press any key to continue . . .

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 Databases Questions!