Skip to content

Course home

Sign up

Subprograms

EasyMediumHard
12345678910111213141516
Question 10

The following pseudocode uses a subprogram to calculate and display a tax receipt.

1  SET receiptHeader TO "--- PRE-CHECK ---"
2
3  PROCEDURE printReceipt ( itemCost, taxRate )
4  BEGIN PROCEDURE
5      SET receiptHeader TO "--- TAX INVOICE ---"
6
7      # calculate tax amount
8      SET taxAmount TO itemCost * taxRate
9
10     # calculate total price
11     SET totalPrice TO itemCost + taxAmount
12
13     # print receipt details
14     SEND receiptHeader TO DISPLAY
15     SEND "Item Price: " & itemCost TO DISPLAY
16     SEND "Tax Amount: " & taxAmount TO DISPLAY
17     SEND "Total: " & totalPrice TO DISPLAY
18 END PROCEDURE
19
20 SEND receiptHeader TO DISPLAY
21 SEND "Enter item cost:" TO DISPLAY
22 RECEIVE cost FROM (REAL) KEYBOARD
23 SEND "Enter tax rate:" TO DISPLAY
24 RECEIVE tax FROM (REAL) KEYBOARD
25 CALL printReceipt(cost, tax)

Explain how the correct value for the variable receiptHeader is chosen on line 14.

[2]
Markscheme

Subprograms Questions

  1. GCSE
  2. /Computer Science
  3. /Subprograms

29 exam-style questions on Edexcel GCSE Computer Science Subprograms, covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank