1 / 24

Chapter 3 - A Methodology for Program Development

Chapter 3 - A Methodology for Program Development. Program Design. Demonstrates understanding of Specifications Answers the question WHAT? Less time Coding and Debugging Program more likely to perform correctly Provides the foundation for GOOD program code.

zack
Download Presentation

Chapter 3 - A Methodology for Program Development

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. Chapter 3 - A Methodology for Program Development

  2. Program Design • Demonstrates understanding of Specifications • Answers the question WHAT? • Less time Coding and Debugging • Program more likely to perform correctly • Provides the foundation for GOOD program code

  3. Tuition Billing General Specifications • Print a report showing each student’s tuition amount due • Amount due is the sum of tuition fees less any scholarship awards • Base tuition $ 200 per credit • Fees • If a Union Member Union Fee = $ 25 • Activity Fee - a sliding scale by number of credits • <= 6 Credits $ 25 • 7 - 12 Credit $ 50 • > 12 Credits $ 75

  4. Tuition Billing General Specifications • Scholarship Amount awarded if GPA is > 2.5 • Print Grand totals of each amount Compute the Tuition due for Bill JonesA Union MemberEnrolled for 15 creditsGPA 3.2Scholarship amount $ 395

  5. Tuition Due Tuition 15 * 200 = $ 3000 Union Member Fee $ 25 Activity Fee $ 75 ===== Subtotal $ 3100 Less Scholarship $ 395 ===== Amount Due $ 2705

  6. Input Record Specifications 01 Student-Record. 05 Student-Name. 10 Last-Name Pic X(15). 10 Initials Pic X(2). 05 Credits Pic 9(2). 05 Union-Member Pic X. 05 Scholarship Pic 9(4). 05 GPA Pix 9v99.

  7. Figure 3.1 Report Format for Tuition Billing Program

  8. ANY COBOL PROGRAM INITIALIZATION PROCESSING TERMINATION Figure 3.2 Overall COBOL Hierarchy Chart

  9. Structured Development • Top - Down • Begin with generalization of function to be performed • Subdivided into less generalization of functions - at lower levels • Continue until lowest level of functions define a single understandable process

  10. Tuition Billing Program 100-Prepare-Tuition-Report

  11. Tuition Billing Program 100-Prepare-Tuition-Report 200-Initialize-Program 210-Process-Student-Records 220-Finalize-Program

  12. Tuition Billing Program 100-Prepare-Tuition-Report 200-Initialize-Program 210-Process-Student-Records 220-Finalize-Program 900-Read- Student-File 300-Compute-Tuition 310-Compute- Fees 330-Compute- Balance-Due 350-Print- Detail-Line 900-Read- Student-File 320-Compute- Scholarship 340-Accumulate- Totals

  13. Completeness • Provides for every function of as called for in the Program Specifications

  14. CONDITION? A B A B (a) Sequence (b) Selection A A ENTRY B EXIT CONDITION? :: TRUE N (c) Iteration (d) Case FALSE Figure 3.4 The Building Blocks of Structured Programming

  15. CONDITION? A C CONDITION2? B TRUE FALSE Figure 3.5 Sufficiency of the Basic Structures

  16. Figure 3.6 Flowchart for Tuition Billing Program PROCESSSTUDENT START COMPUTETUITION OPENFILES COMPUTEUNION FEE READSTUDENTRECORD COMPUTEACTIVITYFEE COMPUTESCHOLARSHIP DATAREMAINS? PROCESSSTUDENT TRUE FALSE INCREMENTUNIVERSITYTOTALS WRITEUNIVERSITYTOTALS WRITEDETAILLINE CLOSEFILES READSTUDENTRECORD STOP STOP (b) Detail of PROCESS-STUDENT (a) Overall Flowchart

  17. Statement AStatement B IF condition is true Statement AELSE Statement BENDIF DO WHILE condition is true Statement AENDDO DO CASE Case 1 is true Statement A Case 2 is true Statement B . . .ENDCASE (a) The Sequence Structure (b) The Selection Structure (c) The Iteration Structure (d) The Case Structure Figure 3.7 Pseudocode for Building Blocks

  18. 100-Prepare-Tuition-Billing-Report. Do 200-Initialize-Program. Do 210-Process-Student-Records until No More Data D0 220-Finalize-Program Stop 200-Initialize-Program. Open files Write heading line(s) Do 900-Read-Student-File 210-Process-Student-Records. Do 300-Compute-Tuition Do 310-Compute-Fees Do 320-Compute-Scholarship Do 330-Compute-Balance-Due Do 340-Accumulate-Totals Do 350-Print-Detail-Line Do 900-Read-Student-Fi;e 220-Finalize-Program. Write university totals Close files Stop run Figure 3.8 Pseudocode for Tuition Billing Program (b) Detailed pseudocode

  19. 300-Compute-Tuition. Compute tuition = 200 * credits 310-Compute-Fees. IF union member union fee = $25 ELSE union fee = 0 ENDIF DO CASE CASE credits <= 6 Activity fee = 25 CASE credits > 6 and <= 12 Activity fee = 50 CASE credits > 12 Activity fee = 75 ENDCASE 320-Compute-Scholarship. IF gpa > 2.5 Scholarship = Scholarship amount ELSE (no scholarship) Scholarship = 0 ENDIF Figure 3.8 Pseudocode for Tuition Billing Program (b) Detailed pseudocode

  20. Figure 3.8 Pseudocode for Tuition Billing Program 330-Compute-Balance-Due. Compute bill = Tuition + Union fee + Activity fee - Scholarship 340-Accumulate-Totals Increment university totals 350-Print-Detail-Line. Write detail line 900-Read-Student-File. Read STUDENT-FILE at end indicate no more data

  21. Statement A Statement B (a) The Sequence Structure Statement A Statement B Condition Condition + (b) The Selection Structure (0, End) Statement A (c) The Iteration Structure Figure 3.9Warnier-Orr Diagrams for Building Blocks

  22. Open filesWrite-heading-lineRead-student-file(1) Compute-tuition (1) Compute-union-fee (1) Compute-activity-fee (1) Compute-scholarship (1) Compute-individual-bill (1) Increment-university-totals (1) Write-detail-line (1) Read-student-file (1) Tuition-Billing Program Process-record(0, End) Write-university-totals (1)Close filesStop run Figure 3.10Warnier-Orr Diagram for Tuition Billing Program

  23. Last-minute panic Amount of testing Amount of testing Time Time (a) Traditional Mode (b) Top-Down Mode Figure 3.13Advantages of Top-Down Testing

  24. End of Chapter 3 Transparencies

More Related