1 / 11

Case Study: Arithmetic with Common Fractions (1)

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.

jalena
Download Presentation

Case Study: Arithmetic with Common Fractions (1)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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

  2. Structure Chart for Common Fraction Problem (2)

  3. Program to Perform Arithmetic Operations on Common Fractions (3)

  4. Program to Perform Arithmetic Operations on Common Fractions (4)

  5. Program to Perform Arithmetic Operations on Common Fractions (5)

  6. Program to Perform Arithmetic Operations on Common Fractions (6)

  7. Program to Perform Arithmetic Operations on Common Fractions (7)

  8. Program to Perform Arithmetic Operations on Common Fractions (8)

  9. Sample Run of a Partially Complete Program Containing Stubs

  10. 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.

  11. Driver for Function scan_fraction

More Related