Note AcademyNote Academy

Computer Science · May / June 2026 · Paper 22 · Question 10

0478

As printed in the paper

The question as text

A program is required to record and analyse the daily rainfall in millimetres for one year. Assume a year has 365 days. The one-dimensional (1D) array y©´›á©¨¨–— is used to store the daily rainfall measurements. Write a program for the following requirements: • Initialise the array y©´›á©¨¨–— to zero. • Input the rainfall measurement in millimetres for each day and store it in the array. • Calculate the following statistics after all the inputs have been made for the year: â the total rainfall for the year in centimetres (1 centimetre = 10 millimetres), rounded to two decimal places â the mean average daily rainfall in millimetres, rounded to four decimal places â the total number of days with no rainfall â the longest number of consecutive days in which there was no rainfall. • Output all the calculated statistics with clear and appropriate messaging. • If the longest number of consecutive days in which there was no rainfall is 15 or more, output You must use pseudocode or program code and add comments to explain how your code works. All arrays, variables or constants used must be declared for this algorithm. All inputs and outputs must contain suitable messages.

Read automatically from the paper; the printed page above is exact.

Show the answer and mark scheme

Use the tables for AO2 and AO3 below to award a mark in a suitable band using a best fit approach, then add up the total.

Marks are available for:

AO2 (maximum 9 marks)
AO3 (maximum 6 marks)

Data structures required with names as given in the scenario:

Arrays or lists Rainfall[]

Requirements (techniques)

R1 Declares of variables and array, initialises array, inputs daily rainfall in mm for a year and stores it in the array (declarations, initialisation, iteration, input, output). R2 Calculates the total rainfall for the year in cm rounded to 2 d.p., the mean average rainfall in mm rounded to 4 d.p., the number of days with no rainfall and the longest period of days with no rainfall (totalling, counting, iteration, rounding, selection, finding max).

R3 Outputs the total rainfall for the year in cm, the average rainfall, the number of days with no rainfall and the longest period of days with no rainfall. Determines if a drought occurred and outputs the result (output, selection).

Example 15-mark answer in pseudocode:

// array and variable declaration

DECLARE Rainfall : ARRAY[1:365] OF REAL

DECLARE Index : INTEGER

DECLARE TotalRain : REAL

DECLARE AverageRain : REAL

DECLARE NoRain : INTEGER

DECLARE DryDays : INTEGER

DECLARE MaxDryDays : INTEGER

// initialising array

FOR Index ← 1 TO 365

Rainfall[Index] ← 0

NEXT Index

// daily input of rainfall

FOR Index ← 1 TO 365

OUTPUT "Input the rainfall measurement for day ", Index INPUT Rainfall[Index]

NEXT Index

// finding the total and average rainfall

TotalRain ← 0

FOR Index ← 1 TO 365

TotalRain ← TotalRain + Rainfall[Index]

NEXT Index

// average daily rainfall to 4dp

AverageRain ← ROUND(TotalRain/365, 4)

// total rainfall in cm to 2dp

TotalRain ← ROUND(TotalRain/10, 2)

// counting the number of days with no rain

NoRain ← 0

FOR Index ← 1 TO 365

IF Rainfall[Index] = 0

THEN

NoRain ← NoRain + 1

ENDIF

NEXT Index

// finding the longest number of consecutive rain free days IF NoRain > 0

THEN

MaxDryDays ← 1

DryDays ← 1

FOR Index ← 1 TO 365-1

IF Rainfall[Index] = 0 AND Rainfall[Index + 1] = 0 THEN

DryDays ← DryDays + 1

IF DryDays > MaxDryDays

THEN

MaxDryDays ← DryDays

ENDIF

ELSE

DryDays ← 1

ENDIF

NEXT Index

ELSE

MaxDryDays ← 0

DryDays ← 0

ENDIF

// outputting the statistics with messages

OUTPUT "The total rainfall for the year was ", TotalRain, " cm" OUTPUT "The average daily rainfall was ", AverageRain, " mm" OUTPUT "The total number of days with no rainfall was ", NoRain, " day(s)"

OUTPUT "The longest period with no rainfall was ", MaxDryDays, " day(s)"

// checking if there was a drought

IF MaxDryDays >= 15

THEN

OUTPUT ""

OUTPUT "There was a drought this year because the longest period with no rainfall was 15 days or longer"

ELSE

OUTPUT ""

OUTPUT "There was no drought this year, because the longest period with no rainfall was shorter than 15 days"

ENDIF

AO2: Apply knowledge and understanding of the principles and concepts of computer science to a given context, including the analysis and design of computational or programming problems

1–3

4–6

Make a free account to save your answers and see your weak topics and ask the AI why a wrong answer is wrong.