Published by Patrick Mutisya · 8 days ago
Use a structure chart to decompose a problem into sub‑tasks and express the parameters passed between the various modules, procedures or functions that form part of the algorithm design.
A structure chart is a hierarchical diagram that shows how a program is broken down into modules and how data flows between them. It helps to:
When specifying parameters, distinguish between:
Problem: Calculate the final grade for a class of students. Each student has marks for three assessments, each weighted differently. The final grade is the weighted sum, rounded to the nearest integer, and then classified as A, B, C, D or F.
| Module | Purpose | Input Parameters | Output Parameters |
|---|---|---|---|
| Main | Coordinates overall processing. | – | – |
| ReadData | Read number of students and their three assessment marks. | – | students[ ][3] (array of marks), n (number of students) |
| ComputeWeightedSum | Calculate \$S = w1 m1 + w2 m2 + w3 m3\$ for each student. | marks[3], weights[3] | rawScore (real) |
| RoundResult | Round the raw score to the nearest integer. | rawScore (real) | roundedScore (integer) |
| ClassifyGrade | Map the rounded score to a grade letter. | roundedScore (integer) | grade (char) |
| OutputResult | Display each student's final grade. | studentID, grade | – |
For a single student, the data flow is:
ReadData supplies marks[3] to ComputeWeightedSum.ComputeWeightedSum returns rawScore to RoundResult.RoundResult returns roundedScore to ClassifyGrade.ClassifyGrade returns grade to OutputResult.Design a structure chart for the following problem and complete the parameter table:
“A library system must allow a user to search for a book by title, check its availability, and if available, issue the book to the user. The system must also update the inventory and record the transaction.”
Guidelines:
ProcessLoan).SearchBook, CheckAvailability, IssueBook, UpdateInventory, RecordTransaction.When you have completed the chart, compare it with the example above to ensure consistency in style and parameter notation.