All variables, constants and other identifiers should have meaningful names. Here is a copy of the pre-release material. DO NOT attempt Tasks 1, 2 and 3 now. Use the pre-release material and your experience from attempting the tasks before the examination to answer Question 1. Pre-release Material Write and test a program to complete the three tasks. TASK 1 A data logger records the temperature on the roof of a school twice a day, at midday and midnight. Input and store the temperatures recorded for a month. You must store the temperatures in two one-dimensional arrays, one for the midday temperatures and one for the midnight temperatures. All the temperatures must be validated on entry and any invalid temperatures rejected. You must decide your own validation rules. You may assume that there are 30 days in a month. TASK 2 Calculate the average temperature for midday and the average temperature for midnight. Output these averages with a suitable message for each one. TASK 3 Select the day with the highest midday temperature and the day with the lowest midnight temperature. Then output each of these temperatures, the corresponding day and a suitable message. Your program must include appropriate prompts for the entry of data. Error messages and other outputs need to be set out clearly and understandably. All variables, constants and other identifiers must have meaningful names. Each task must be fully tested.
- (a)(i)In Task 1, you had to store the midday temperatures and midnight temperatures in arrays. Write suitable declarations for these two arrays.[2]
- (a)(ii)It has been decided to record the temperatures for one week rather than one month. Write the new array declarations that you would use.[1]
- (a)(iii)Declare two other variables that you have used and state what you used each one for. Variable 1 Use Variable 2 Use[4]
- (b)Write an algorithm to complete Task 2, using either pseudocode, programming statements or a flowchart. Use temperatures for one week only. You should assume that Task 1 has already been completed.[5]
- (c)Give a set of midday temperature data, for a week, that could be used to check your validation rules for Task 1. Explain why you chose this data set. Data set Reason for choice[2]
- (d)Explain how you select the day with the highest midday temperature (part of Task 3). You may include pseudocode or programming statements as part of your explanation.[6]
Mark scheme
Marking points from the official mark scheme (May/June 2015). The mark or mark type is shown in brackets.
- [1] (a) (i) MiddayTemperature[1:30]
- [1] (a) (i) MidnightTemperature[1:30]
- [1] (a) (ii) MiddayTemperature[1:7] MidnightTemperature[1:7]
- [1] (a) (iii) Counter: (Integer)
- [1] (a) (iii) to use as a loop counter when entering the temperature
- [1] (a) (iii) HighNoon: (Real)
- [1] (a) (iii) to store the highest midday temperature
- [4] (b) If loop used initialisation before loop loop running total inside loop calculation of average outside loop output of average with message outside loop
- [1] (b) completion of at least 3 of initialisation, running total, calculation of average and output of average with message for both midday and midnight
- [5] (b) Sample Algorithm: MiddayTotal ← 0; MidnightTotal ← 0 FOR Count ← 1 ΤΟ 7 MiddayTotal ← MiddayTotal + MiddayTemperature[Count] MidnightTotal ← MidnightTotal + MidnightTemperature [Count] NEXT Count MiddayAverage ← MiddayTotal/7 MidnightAverage ← MidnightTotal/7 PRINT 'The average midday temperature is ', MiddayAverage PRINT 'The average midnight temperature is ', MidnightAverage
- [5] (b) If loop not used total of 7 midday temperatures calculation of midday average (Note could be combined as one calculation, see example below) total of 7 midnight temperatures calculation of midnight average (Note could be combined as one calculation, see example below) output of both averages with suitable messages
- [2] (c) Data set: 30, 29, 28, 31.5, 32.3, 33, 29.7 (normal data that should be accepted) OR Data set: twenty, 23.99, seventeen, 501, −273, @#@, seventy seven (abnormal data that should be rejected)
- [6] (d) Explanation (max 6): set variable called HighestMidday to a large minus number; loop (30 or 7) times to check each midday temperature in turn; check midday temperature against HighestMidday / midday temperature > Highest Midday; ...replace value in HighestMidday by midday temperature; ...store array index in MiddayMonthDay/MiddayWeekday; output HighestMidday outside the loop; output MiddayMonthDay/MiddayWeekday outside the loop
- [4] (d) Sample algorithm (max 4): HighestMidday ← -999 FOR Count ← 1 ΤΟ 7 IF MiddayTemperature [Count] > HighestMidday THEN HighestMidday ← MiddayTemperature[Count] MiddayMonthDay/MiddayWeekday ← Count ENDIF NEXT Count PRINT 'The highest midday temperature was ',HighestMidday, ' on day ', Count
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 →