Write a C++ fraction calculator program that adds, subtracts, multiplies, and divides fractions. Your program should check for the division by 0, have and use the following functions: (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 positive integers. (d) reduce - reduces a given fraction. (e) flip - reduces a given fraction and flips the sign if the denominator is negative. (f) add - finds the reduced sum of a pair of given fractions. (g) subtract - finds the reduced difference of a pair of given fractions, by making the second fraction negative then using the add function. (h) multiply - finds the reduced product of a pair of given fractions. (i) divide - finds the reduced quotient of a pair of given fractions by inverting the second fraction then using the multiply function. Sample Runs: Fraction Calculator 1.0 Enter an arithmetic expression of the form a/b operator c/d, replace operator by any one of +, -, *, or / ˜$ 2/4 + 1/3 Solution: (1/2) + (1/3) = 5/6 Again (Y/N)? Y
Write a C++ fraction calculator program that adds, subtracts, multiplies, and divides fractions. Your program should check for the division by 0, have and use the following functions:
(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 positive integers.
(d) reduce - reduces a given fraction.
(e) flip - reduces a given fraction and flips the sign if the denominator is negative.
(f) add - finds the reduced sum of a pair of given fractions.
(g) subtract - finds the reduced difference of a pair of given fractions, by making
the second fraction negative then using the add function.
(h) multiply - finds the reduced product of a pair of given fractions.
(i) divide - finds the reduced quotient of a pair of given fractions by inverting the second fraction then using the multiply function.
Sample Runs:
Fraction Calculator 1.0
Enter an arithmetic expression of the form a/b operator c/d,
replace operator by any one of +, -, *, or / ˜$ 2/4 + 1/3
Solution: (1/2) + (1/3) = 5/6
Again (Y/N)? Y
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images