A weather station takes temperature readings once an hour for a week. These temperatures are stored in a two-dimensional (2D) array Temperatures[] Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and the final temperature at 23:00. There are seven columns, one for each day of the week, starting with Monday and ending with Sunday. The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and average temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store the maximum, minimum, and average temperatures for the week. The array has already been set up and the data stored. Write a program that meets the following requirements: • finds the maximum and minimum temperatures for each day • calculates the average temperature for each day • outputs for each day: – name of the day, for example Monday – maximum temperature – minimum temperature – average temperature • finds the maximum and minimum temperatures for the week • calculates the average temperature for the week • outputs: – maximum temperature for the week – minimum temperature for the week – average temperature for the week. All temperatures output must be rounded to two decimal places. You must use pseudocode or program code and add comments to explain how your code works. All inputs and outputs must contain suitable messages. You do not need to declare any arrays or variables; you may assume that this has already been done. You do not need to initialise the data in the array Temperatures[]
- A weather station takes temperature readings once an hour for a week. These temperatures are stored in a two-dimensional (2D) array Temperatures[] Each column contains 24 readings for a single day. The first temperature is recorded at 00:00 and the final temperature at 23:00. There are seven columns, one for each day of the week, starting with Monday and ending with Sunday. The variables MaxDay, MinDay and AvDay are used to store the maximum, minimum, and average temperatures for a day. The variables MaxWeek, MinWeek and AvWeek are used to store the maximum, minimum, and average temperatures for the week. The array has already been set up and the data stored. Write a program that meets the following requirements: • finds the maximum and minimum temperatures for each day • calculates the average temperature for each day • outputs for each day: – name of the day, for example Monday – maximum temperature – minimum temperature – average temperature • finds the maximum and minimum temperatures for the week • calculates the average temperature for the week • outputs: – maximum temperature for the week – minimum temperature for the week – average temperature for the week. All temperatures output must be rounded to two decimal places. You must use pseudocode or program code and add comments to explain how your code works. All inputs and outputs must contain suitable messages. You do not need to declare any arrays or variables; you may assume that this has already been done. You do not need to initialise the data in the array Temperatures[][15]
Mark scheme
Marking points from the official mark scheme (Oct/Nov 2023). The mark or mark type is shown in brackets.
- AO2 (maximum 9 marks)
- AO3 (maximum 6 marks)
- Data Structures required names shown underlined must be used as given in the scenario 2D Array or list Temperatures Variables MaxDay, MinDay, AvDay, MaxWeek, MinWeek, AvWeek
- Requirements (techniques) R1 Find maximum and minimum temperatures for each day and calculates the average daily temperature (searching, totalling) R2 Find maximum and minimum temperatures for week and calculates the average weekly temperature (nested searching, totalling) R3 outputs for each day name, the rounded values for maximum temperature, minimum temperatures and average temperature. Outputs for the week the rounded values for maximum temperature, minimum temperatures and average temperature (output with appropriate messages and rounded values)
- Example 15-mark answer in pseudocode: // meaningful identifier names and appropriate data structures to store the data required DECLARE DayCounter, HourCounter : INTEGER DECLARE AvDay, AvWeek, MaxDay, MinDay, MaxWeek, MinWeek : REAL DECLARE DayTotal, WeekTotal : REAL DECLARE Day : STRING CONSTANT Hours ← 24 CONSTANT Days ← 7 MaxWeek ← -1000// initialise max and min temperatures and total for the week MinWeek ← 1000 WeekTotal ← 0 FOR DayCounter ← 0 TO Days - 1 MaxDay ← -1000// initialise max and min temperatures and total for each day MinDay ← 1000 DayTotal ← 0 FOR HourCounter ← 0 TO Hours - 1 DayTotal ← DayTotal + Temperatures(HourCounter, DayCounter) // update total maximum and minimum IF Temperatures(HourCounter, DayCounter) > MaxDay THEN MaxDay ← Temperatures(HourCounter, DayCounter) ENDIF IF Temperatures(HourCounter, DayCounter) < MinDay THEN MinDay ← Temperatures(HourCounter, DayCounter) ENDIF NEXT HourCounter CASE OF DayCounter // select message for day 0 : Day ← "Monday" 1 : Day ← "Tuesday" 2 : Day ← "Wednesday" 3 : Day ← "Thursday" 4 : Day ← "Friday" 5 : Day ← "Saturday" 6 : Day ← "Sunday" ENDCASE DayAverage ← DayTotal / Hours // output results for day OUTPUT Day // Results from a day OUTPUT "Maximum temperature ", MaxDay OUTPUT "Minimum temperature ", MinDay OUTPUT "Average temperature ", ROUND(DayAverage,2) IF MaxDay > MaxWeek // update total maximum and minimum THEN MaxWeek ← MaxDay ENDIF IF MinDay < MinWeek THEN MinWeek ← MinDay ENDIF WeekTotal ← WeekTotal + DayTotal // update total for week NEXT DayCounter WeekAverage ← WeekTotal / Days OUTPUT "Maximum temperature for week ", MaxWeek// output results for week OUTPUT "Minimum temperature for week ", MinWeek OUTPUT "Average temperature for Week ", ROUND(WeekAverage,2)
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 →