Write a FRACTION calculator program with c++ 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.
Write a FRACTION calculator
-
(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.
Step by step
Solved in 2 steps