The manager of a building materials delivery service needs a program to check the contents and weight of sacks to ensure that correct orders are made up for delivery. A price for the order will be calculated. Write and test a program for the manager. • Your program must include appropriate prompts for the entry of data. • Error messages and other output need to be set out clearly. • All variables, constants and other identifiers must have meaningful names. You will need to complete these three tasks. Each task must be fully tested. TASK 1 - Check the contents and weight of a single sack • Each sack must obey the following rules to be accepted: contain cement, gravel or sand, with a letter on the side for easy identification o C - cement o G - gravel o S - sand sand or gravel must weigh over 49.9 and under 50.1 kilograms cement must weigh over 24.9 and under 25.1 kilograms Input and store the weight and contents for one sack. The contents must be checked and an incorrect sack rejected. The weight must be validated on entry and an overweight or underweight sack rejected. Output the contents and weight of an accepted sack. If a sack is rejected, output the reason(s). TASK 2 - Check a customer's order for delivery Input and store the number of sacks of each type required for the order. Use TASK 1 to check the contents and weight of each sack. Ensure that the delivery contains the correct number and type of sacks for the order. Output the total weight of the order. Output the number of sacks rejected from the order. TASK 3 - Calculate the price for a customer's order • Extend TASK 2 to calculate a price for an order. Prices for the sacks are as follows: regular price for each sack o cement, $3 o gravel, $2 o sand, $2 • discount price for a special pack containing 1 sack of cement, 2 sacks of sand and 2 sacks of gravel, $10 Calculate and output the regular price for the order. Check how many special packs are in the order. If a discount price applies then output the new price for the order and the amount saved. (a) All variables, constants and other identifiers should have meaningful names.
- (a)(i)For three of the variables that you have used in Task 2, state the name, type and its use.[3]
- (a)(ii)State three constants that you could have used for Task 1. Give the value that would be assigned to each one.[3]
- (b)Write an algorithm to complete Task 2, using either pseudocode, programming statements or a flowchart. You can assume that the weight and contents have already been checked and accepted in Task 1. You do not need to output the number of sacks rejected.[5]
- (c)(i)Give two different data values that could be used to check your validation rules for sand in Task 1. Explain why you chose each value.[2]
- (c)(ii)Give two different data values that could be used to check your validation rules for cement in Task 1. Explain why you chose each value.[2]
- (d)Explain how your program calculates the price for an order (Task 3). You may include programming statements as part of your explanation.[5]
Mark scheme
Marking points from the official mark scheme (May/June 2016). The mark or mark type is shown in brackets.
- [1] NumSacks, integer, number of sacks
- [1] SacksAccepted, integer, number of sacks accepted
- [1] TotalWeight, real, total weight of all sacks
- [1] TopWeight, 50.1
- [1] BottomWeight 49.9
- [1] TopWeightCement 25.1
- [1] BottomWeightCement 24.9
- [1] initialise total weight of order
- [1] input number of sacks for each type outside loop(s)
- [1] loop for order completion
- [1] input weight inside loop(s)
- [1] add weight of accepted sack to total weight
- [1] output total weight outside all loop(s)
- [1] appropriate prompts for input number of sacks for each type and input weight
- [1] Data value 49.95; Reason - normal data sand should be accepted
- [1] Data value 50.1; Reason - boundary data sand should be rejected
- [1] Data value 25; Reason - normal data cement should be accepted
- [1] Data value 26.7; Reason - abnormal data cement that should be rejected
- [1] use of prices for calculation of regular price either numbers, variables or constants (sand and gravel 2, cement 3)
- [1] description of calculation of regular price, multiply no of sand sacks by 2, multiply no of gravel sacks by 2, multiply no of cement sacks by 3
- [1] output of regular price
- [1] description of calculating the number of special packs using the pack information (2 sacks of sand, 2 sacks of gravel and 1 sack of cement)
- [1] .......repeat until there are no more packs in the order (less than 2 sacks of sand or less than 2 sacks of gravel or no sacks of cement
- [1] calculation of discount price and/or amount saved
- [1] output discount price and/or amount saved
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 →