CAMBRIDGE IGCSE COMPUTER SCIENCE
Summer 2023 · Paper 21 · Question 11 · 15 marks
← 0478 CS Hub Paper 21 · Summer 2023 0478 / Paper 2 Question 11 15 MARKS
15-mark question lab · start here

From a week of hourly readings to daily and weekly averages.

Build the solution in a sensible order: decode the six requirements, plan the three arrays, populate Days[], read and validate every hourly temperature, total each day and store its rounded average, average the week, then convert every figure to Fahrenheit and report. Learn the reasoning before revealing the complete program.

2D arrayRange validationTotallingCelsius-to-Fahrenheit conversionRounding to 1 dp15 marks

Learning targets

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

Lesson overview

01 · Understand

Identify the three arrays and their shared day index, the inclusive range −20.0 °C to +50.0 °C, and the six requirements hidden in the bullet list.

02 · Construct

Build the program in order: populate Days[], read and validate every hourly temperature in nested loops, total each day, and store each rounded daily average in AverageTemp[].

03 · Complete

Average the week from the stored daily values, convert every average with Fahrenheit = Celsius * 9 / 5 + 32, and output each day and the whole week in both scales, rounded to one decimal place.

!

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 shared day index, the inclusive temperature range and the two-scale outputs all affect the structure of your solution.

Question 11 · 15 marks
Cambridge IGCSE Computer Science · 0478/21 · Question 11

A one-dimensional (1D) array Days[] contains the names of the days of the week. A two-dimensional (2D) array Readings[] is used to store 24 temperature readings, taken once an hour, for each of the seven days of the week. A 1D array AverageTemp[] is used to store the average temperature for each day of the week.

The position of any day’s data is the same in all three arrays. For example, if Wednesday is in index 4 of Days[], Wednesday’s temperature readings are in index 4 of Readings[] and Wednesday’s average temperature is in index 4 of AverageTemp[]

The temperature readings are in Celsius to one decimal place. Temperatures can only be from –20.0 °C to +50.0 °C inclusive.

Write a program that meets the following requirements:

  • input and validate the hourly temperatures for one week
  • calculate and store the average temperature for each day of the week
  • calculate the average temperature for the whole week
  • convert all the average temperatures from Celsius to Fahrenheit by using the formula Fahrenheit = Celsius * 9 / 5 + 32
  • output the average temperature in Celsius and in Fahrenheit for each day
  • output the overall average temperature in Celsius and in Fahrenheit for the whole week.

You must use pseudocode or program code and add comments to explain how your code works.

You do not need to declare any arrays, variables or constants; you may assume that this has already been done.

All inputs and outputs must contain suitable messages.

All data output must be rounded to one decimal place.

You will need to initialise and populate the array Days[] at the start of the program.

Before you move on

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

Mark-scheme map
R1

Input and store the hourly temperatures for every day of the week, with prompts and nested iteration over days and hours.

R1

Validate each input against the range −20.0 °C to +50.0 °C inclusive, and re-ask until the value is valid.

R2

Total each day’s readings and store the daily average in AverageTemp[], rounded to one decimal place.

R2

Total the stored daily averages and calculate the weekly average, also rounded to one decimal place.

R3

Convert all average temperatures with Fahrenheit = Celsius * 9 / 5 + 32 and output the daily and weekly figures in both scales with appropriate messages.

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.