CMIS 102
Homework
Due:
Turn in print out of source code and diskette with the file.
Fun with fractions.
Write a program that will calculate fractional expressions. The user
enters an expression with 2 fractions and one of the four basic
arithmetic operators (addition, subtraction, multiplication, and
division). The fractions will be input as two numbers separated by a
/. Some examples of what the user can enter:
3/4 + 2/ 7
1.54 /.9*253/99.9
The numerators and denominators are floats. The program will read a
float, a char (the /), a float, a char for the operation to do, a
float, a char (the /), a float in that order. The examples show that
spaces have no effect, they're skipped by cin.
The program will detect zero denominators and output an error message.
The program will detect an invalid operator and output an error message.
The program divides the first numerator by the first denominator to
determine the first quotient, divides the second pair to get the
second quotient, and then, based on the operation character, add, or
subtract, or multiply, or divide the two quotients.
The outputted result is a single float value (not a fraction, that's a
more difficult program). For example, the output for the first
example above is 1.03571