7. Algorithm design and problem-solving
A section of Computer Science, 0478
Listing 10 of 61 questions
Students in a class are recording the amount of time in minutes spent in front of a screen for each day of the week. The one-dimensional (1D) array StudentName contains the names of the students in the class. The two-dimensional (2D) array ScreenTime is used to input the number of minutes on each day spent in front of a screen. The position of each student’s data in the two arrays is the same. For example, the student stored at index 10 in StudentName and ScreenTime is the same. The variable ClassSize contains the number of students in the class. Write a program that meets these requirements: • allows all the students to enter their daily minutes of screen times for the past week • calculates the total number of minutes of screen time for each student in the week • counts, for each student, the number of days with more than 300 minutes of screen time • calculates the average weekly minutes of screen time for the whole class • finds the student with the lowest weekly minutes of screen time • outputs for each student: – name – total week’s screen time in hours and minutes – number of days with more than 300 minutes of screen time • outputs the average weekly minutes of screen time for the whole class • outputs the name of the student with the lowest weekly screen time. You must use pseudocode or program code and add comments to explain how your code works. All inputs and outputs must contain suitable messages. Assume that the array StudentName and the variable ClassSize already contain the required data. You do not need to declare any arrays or variables; you may assume that this has already been done.
0478_m24_qp_22
THEORY
2024
Paper 2, Variant 2
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.
0478_s23_qp_21
THEORY
2023
Paper 2, Variant 1
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
0478_w23_qp_23
THEORY
2023
Paper 2, Variant 3
0478_w24_qp_22
THEORY
2024
Paper 2, Variant 2
A one-dimensional (1D) array Teams contains the names of 10 football teams in a local league. A two-dimensional (2D) array Results stores, for each team, the total number of: • games won • games drawn • games lost • points. The position of any team’s data is the same in both arrays. For example the data in index 3 of Results belongs to the team in index 3 of Teams The array data will be used to find the current leader of the league. The variable Played stores the number of games played by each team. Each team plays the same number of games. Write a program that meets the following requirements: • allows the number of games played to be input and stored, with a maximum of 18 games • allows the names of the teams to be input and stored • allows the number of games won, drawn and lost to be input and stored for each team • validates the number of games played and the number of games won, drawn or lost against the number of games played • calculates and stores the number of points for each team using three points for a win and one point for a draw; there are no points for a loss • sorts the array Results into descending order of number of points, ensuring the corresponding parallel array Teams is kept in the same order • determines how many teams have the highest number of points • outputs the nameof the winning teamalong with the number of points achieved. 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.
0478_s24_qp_23
THEORY
2024
Paper 2, Variant 3
Questions Discovered
61