Question
Write a fraction calculator c++ program that adds,subtracts, multiplies, and divides fractions. Your program shouldcheck for the division by 0, have and use the followingfunctions:
Write a fraction calculator c++ program that adds,subtracts, multiplies, and divides fractions. Your program shouldcheck for the division by 0, have and use the followingfunctions:
(a) abs- returns the absolute value of a given integer.
(b) min- returns the smallest of two positive integers.
(c) gcd- returns the greatest common divisor of two positiveintegers.
(d) reduce- reduces a given fraction, makes sure that thenegative value, if any, is only in the denominator.
(e) flip- flips and reduces a given fraction.
(f) add- finds the reduced sum of a pair of given fractions.
(g) subtract- finds the reduced difference of a pair of givenfractions, by making the second fraction negative then using theadd function.
(h) multiply- finds the reduced product of a pair of givenfractions.
(i) divide-finds the reduced quotient of a pair of givenfractions by flipping the second fraction then using the multiplyfunction.
Sample Runs:
Fraction Calculator 1.0
Enter an arithmetic expression of the form a/b @ c/d, replace @by any one of +, -, *, or /
?> 2/4 + 1/3
Solution: (1/2) + (1/3) = 5/6
Again (Y/N)? Y
?> 1/-3 - 5/6
Solution: (-1/3) - (5/6) = -7/6
Again (Y/N)? Y
?> 4/5*-2/-10
Solution: (4/5)*(1/5) = 4/25
Again (Y/N)? Y
?> 6/3 / 1/3
Solution: (2/1) / (1/3) = 6/1
Again (Y/N)? N
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started