I need to create a program titled Division. Here are the specifics:
Have the program prompt the user "Enter numerator and denominator" and store the two values entered. (If you wish the user to "Enter numerator/denominator" be sure to adjust your data gathering variables to include a holder variable for the slash character.)
Define an exception class divByZero and have the function Quotient use throw for an exception of this type if the denominator is 0. Display output "You cannot have a denominator that is equal to 0."
Quotient throws an exception to the higher-level function main to decide whether or not the program should be terminated. Main catches the divByZero and prints out an appropriate comment on the screen. Also include in main a try block to catch the divide-by-zero error.
If no exception occurs, print out a message "The quotient is xxxxx."© BrainMass Inc. brainmass.com October 25, 2018, 9:16 am ad1c9bdddf
The solution gives a complete c++ program for performing division operations.
Write a program that lets the user perform arithmetic operations on fractions. Fractions are of the form a/b, where a and b are integers and b is not equal to 0. Your program must be menu driven, allowing the user to select the operation (+, -, *, /) and input the numerator and denominator of each fraction. Your program must consist of at least the following functions:
a. Function menu: This function informs the user about the program's purpose, explains how to enter data, and allows the user to select the operation.
b. Function addFractions: This function adds two fractions together (or you can overload the +operator()).
c. Function subtractFractions: This function subtracts one fraction from another (or you can overload the -operator()).
d. Function multiplyFractions: This function multiplies two fractions together (or you can overload the *operator()).
e. Function divideFractions: This function divides one fraction into another (or you can overload the /operator()).
Some sample outputs are:
3 / 4 + 2 / 5 = 23 / 20
2 / 3 * 3 / 5 = 6 / 15
Your answers need not be in the lowest terms.View Full Posting Details