110 likes | 237 Views
Case Study: Arithmetic with Common Fractions (1). Design program which allows you to add, subtract, multiply, an divide two input common fractions. And display the results in common fractions in reduced form. After a calculation, it prompts the user to do another calculation or to quit.
E N D
Case Study: Arithmetic with Common Fractions (1) • Design program which allows you to add, subtract, multiply, an divide two input common fractions. And display the results in common fractions in reduced form. After a calculation, it prompts the user to do another calculation or to quit. • Analysis • Inputs two common fractions n1/d1, n2/d2, and an operation, op i.e., +, -, *, or / • Output: n_ans/d_ans in reduced form • Initial Algorithm • Repeat as long as user wants to continue • Get the first operand n1/d1 • Get a operation op • Get another operand n2/d2 • Compute n1/d1 op n2/d2 according to op • Do the reduction • Display the result n_ans/d_ans • Check if user wants to continue
Program to Perform Arithmetic Operations on Common Fractions (3)
Program to Perform Arithmetic Operations on Common Fractions (4)
Program to Perform Arithmetic Operations on Common Fractions (5)
Program to Perform Arithmetic Operations on Common Fractions (6)
Program to Perform Arithmetic Operations on Common Fractions (7)
Program to Perform Arithmetic Operations on Common Fractions (8)
Stub for Function multiply_fraction What is a stub?_ a function skeleton with dummy values to its oupt put paramenters, used for testing partial system.