A program will calculate the tax payable based on the cost of an item. Calculations will occur at many places in the program and these involve the use of one of three tax rates. Tax rate values represent a percentage. For example, a tax rate value of 5.23 represents 5.23%. In this case, the tax payable on an item costing $100 would be $5.23. Tax rate values are used at several places within the program. One example is given in pseudocode as follows: HighRate ← FALSE CASE OF ItemCost <= 50 : TaxRate ← 3.75 // tax rate of 3.75% <= 200 : TaxRate ← 5.23 // tax rate of 5.23% > 200 : TaxRate ← 6.25 // tax rate of 6.25% HighRate ← TRUE ENDCASE TaxPayable ← ItemCost * TaxRate // tax payable
- (a)The pseudocode contains a logical error. Identify the error and suggest a correction. Error Correction[2]
- (b)(i)During the design of the program, tax rate values have been used wherever they are needed as shown in the pseudocode example above. Tax rates do not change while the program runs. Identify a more appropriate way of representing the tax rate values in the final program.[1]
- (b)(ii)Describe the benefits of your answer to part (b)(i) with reference to this program.[3]
- (c)Give the appropriate data type for the variables in the following table, as used in the pseudocode: Variable name | Data type ---|--- HighRate | TaxPayable |[2]
- (d)The final CASE condition (> 200) in the pseudocode example could be replaced with a keyword. Give the keyword.[1]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2024). The mark or mark type is shown in brackets.
- [1] (a) Error: The calculation of TaxPayable is incorrect
- [1] (a) Correction: TaxPayable ← (ItemCost * TaxRate) / 100
- [1] (b)(i) Use constants (to represent the tax rate values)
- [1] (b)(ii) Tax rates are entered once only
- [1] (b)(ii) Avoids / Minimise (input) error(s) / changing the Tax rates accidentally // avoids different values for tax rates at different points in the program
- [1] (b)(ii) When required, the constant value (representing a tax rate) is changed (once) // Easier to maintain / update the program (when the tax rates change)
- [1] (b)(ii) Makes the program / code easier to understand
- [1] (c) HighRate: Boolean
- [1] (c) TaxPayable: Real
- [1] (d) OTHERWISE
Write your answer and get it marked
On Oracle Prep you can write or photograph your own answer and have it marked by AI against this mark scheme, with feedback on what you missed.
Sign up free →