Question: Write a program that carries out the basic arithmetic operations, namely, - multiplication - division - addition, and - subtraction on rational numbers. The set

Write a program that carries out the basic arithmetic operations, namely, - multiplication - division - addition, and - subtraction on rational numbers. The set of rational numbers contains all values that can be expressed as the ratio of two integers. Therefore, each rational number is specified by TWO integers (anumerator / denominator). The program prompts the user to enter two rational numbers, say, x and y. Let us assume that the user enters the pair of integers a and b for x and the pair of integers c and d for y. Given x=(a/b) and y=(c/d), the program outputs the product, ratio, sum and difference of x and y as follows: xy=(a/b)(c/d)=(ac/bd)x/y=(a/b)/(c/d)=(ad/bc)x+y=(a/b)+(c/d)=(ad+bc)/(bd)xy=(a/b)(c/d)=(adbc)/(bd) Note: Each result should be printed as a rational number in the form: (numerator/denominator) Here is a sample of the program output: Enter numerator and denominator of first rational number, x:34 Enter numerator and denominator of Second rational number, y: 57 xy=(3/4)(5/7)=(15/28)x/y=(3/4)/(5/7)=(21/20)x+y=(3/4)+(5/7)=(41/28)xy=(3/4)(5/7)=(1/28)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
