CAMBRIDGE IGCSE COMPUTER SCIENCE
Winter 2023 · Paper 23 · Question 10 · 15 marks
← 0478 CS Hub Paper 23 · Winter 2023 0478 / Paper 2 Question 10 15 MARKS
15-mark question lab · start here

From a grid of hourly readings to a week of weather reports.

Build the solution in a sensible order: decode the six requirements, plan the counters and sentinels, scan each day’s column for its maximum, minimum and total, output every day’s rounded line, feed the week trackers, then print the week’s three results. Learn the reasoning before revealing the complete program.

Columns are daysNested loopsMax and min sentinelsAverages and roundingCASE OF day names15 marks

Learning targets

By the end, you should be able to explain the algorithm before writing it.

Lesson overview

01 · Understand

Identify the given 2D array Temperatures[] with a column for each day, the six given variables MaxDay, MinDay, AvDay, MaxWeek, MinWeek and AvWeek, and the six requirements hidden in the bullet list.

02 · Construct

Build the program in order: reset the day sentinels inside the day loop, scan each day’s column with the hour loop, total the readings and track the maximum and minimum, then output each day’s name and three rounded values.

03 · Complete

Feed each day’s finished results into MaxWeek, MinWeek and WeekTotal, calculate the rounded weekly average from every reading, and output the week’s three results after the loop.

!

How Cambridge awards the marks: the mark scheme gives AO2 a maximum of 9 marks and AO3 a maximum of 6 marks. It lists requirements R1–R5, but does not assign a separate fixed mark total to each R requirement. The stage-to-mark links in this guide show alignment, not invented stage marks.

Source question

Read the whole question first

Do not begin coding after the first paragraph. The column-per-day layout, the six given variables and the two levels of maximum-and-minimum tracking all affect the structure of your solution.

Question 10 · 15 marks
Cambridge IGCSE Computer Science · 0478/23 · Question 10

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[]

Before you move on

These are the five required techniques identified by the Cambridge mark scheme.

Mark-scheme map
R1

Find the maximum and minimum temperatures for each day — searching each day’s column with strict comparisons.

R1

Calculate the average daily temperature — totalling the day’s readings and dividing by the reading count.

R2

Find the maximum and minimum temperatures for the week — nested searching that compares each day’s finished results with the week trackers.

R2

Calculate the average weekly temperature — totalling every reading of the week and dividing by the number of readings.

R3

Output each day’s name with its rounded maximum, minimum and average, then the week’s rounded maximum, minimum and average — appropriate messages and rounded values throughout.

Use the tabs along the top to work through the seven stages. The complete solution is kept in its own tab, and the interactive visualisation is the final tab.