Question: Write a program that reads two fractions, adds them, and prints the result so that the numerator and denominator have no common factor. For example,

Write a program that reads two fractions, adds them, and prints the result so that the numerator and denominator have no common factor. For example, when adding 3/4 and 5/6, the result is 19/12. Use helper functions for obtaining the numerator and denominator of strings such as "3/4", and for computing the greatest common divisor of two integers.

Step by Step Solution

3.34 Rating (160 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Here is a sample implementation in Python def gcda b Compute the greatest common divisor of a and b ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Java Concepts Late Objects Questions!