0% found this document useful (0 votes)
6 views2 pages

Programming Scenarios (1)

The document outlines a programming scenario for processing temperature data collected hourly over a week, stored in a two-dimensional array. It specifies the requirements for calculating and outputting daily and weekly maximum, minimum, and average temperatures, along with structured comments for code implementation. The output must be formatted with suitable messages and rounded to two decimal places.

Uploaded by

manhamehrin.t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views2 pages

Programming Scenarios (1)

The document outlines a programming scenario for processing temperature data collected hourly over a week, stored in a two-dimensional array. It specifies the requirements for calculating and outputting daily and weekly maximum, minimum, and average temperatures, along with structured comments for code implementation. The output must be formatted with suitable messages and rounded to two decimal places.

Uploaded by

manhamehrin.t
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Programming Scenarios Practise : April 1st (From paper 23, 2023)

In class we already identified the following:

Input(s): 2 dimensional array: Temperatures[ ][ ]


Processes: Loop per day, and loop per hour

Output: For each day, name, max, min, average


Once, for the week: max, min, average

The Temperatures array can be visualised as follows: [row number][column number]

Monkey Tuesday Wednesday Thursday Friday Saturday Sunday


[0][0] [0][1] [0][2] [0][3] [0][4] [0][5] [0][6]

[1][0] [1][1] [1][2] … …

[2][0] [2][1] [1][3] … …

[3][0] [3][1]

….. ….

….. ….

…… ….

[22][0] [22][1] [22][5] [22][6]

[23][0] [23][1] [23][5] [23][6]

So far, structured comments are:

#initialise variables
(note these will be of type float (python specific), and real (pseudocode)

# loop through each day


#for each day, loop through the hours

#print results
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[]

You might also like