0% found this document useful (0 votes)
70 views1 page

Homework 2: Structured Programming: Unit 2 Problem Solving

This document provides details for Homework 2 on structured programming. It includes: 1. A pseudocode program that will output "Homer", "Marge", or "Bart" depending on conditions and will produce 13 lines of output when traced. 2. Questions asking to describe three features of structured programming and list four benefits. 3. Steps for processing invoices that involve opening files, reading data, calculating prices and totals, printing invoices, and closing files. A hierarchy chart is to be drawn showing the major tasks and subtasks.

Uploaded by

Jesse Opoku
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
70 views1 page

Homework 2: Structured Programming: Unit 2 Problem Solving

This document provides details for Homework 2 on structured programming. It includes: 1. A pseudocode program that will output "Homer", "Marge", or "Bart" depending on conditions and will produce 13 lines of output when traced. 2. Questions asking to describe three features of structured programming and list four benefits. 3. Steps for processing invoices that involve opening files, reading data, calculating prices and totals, printing invoices, and closing files. A hierarchy chart is to be drawn showing the major tasks and subtasks.

Uploaded by

Jesse Opoku
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Homework 2 Structured programming

Unit 2 Problem solving

Homework 2: Structured programming


1. (a) How many lines of output will the following pseudocode program produce? [1]

(b) Trace through the program and write down what is output. [4]
FOR a = 8 to 19 step 4
FOR b = 1 to 3
IF a mod b >= b/3 THEN
IF a/4 <= b+1 THEN
OUTPUT “Homer”
ELSE
OUTPUT “Marge”
ENDIF
ELSE
OUTPUT “Bart”
ENDIF
ENDFOR
ENDFOR

2. (a) Describe three features of structured programming. [6]


(b) List four benefits of using structured programming techniques. [4]

3. The following steps are followed when processing invoices for a batch of customer orders.
Details such as description and price of each stock item are held on a Product file.
Discounts are calculated depending on the total value of the order. Details of all sales are
held on a Sales file. Customer details are held on a Customer file.
Open Product file, Customer file and Sales file
initialise variables
Read Sales file to find last invoice number
for each order
Read Customer file to get customer details
print invoice number, customer details
increment invoice number
for each item on the order
Input the item code, quantity
look up description and price
calculate price*quantity
print line of order
endfor
calculate overall gross total
calculate discount and net price
print total discount and invoice total
update Sales file
endfor
close files

Draw a hierarchy chart showing the major tasks and subtasks involved. [5]
[Total 20 marks]

You might also like