Homework 10
Write a program that reads in two fractions from the user and prints out the sum of the two numbers in lowest terms. Recall (from grade school!) that
n1 n2 n1 d2 + n2 d1-- + -- = -------------d1 d2 d1 d2
and that to reduce a fraction to lowest terms you divide the numerator n and the denominator d by the greatest common divisor of n and d. Of course, in the lecture notes we discuss greatest common divisor! A run of your program should look something like this:
Enter a fraction addition problem: 15/28 + 7/32 15/28 + 7/32 = 169/224 |
Turn In a printout of your code, along with a screen capture of your
program running on input 15/28 + 7/32.