Question 9
OCR Computer Science June 2024 Computational thinking, algorithms and programming (J277-02)GCSE30 marks
On the specification
- (a)(i)
- 2.2 Programming fundamentals
- (a)(ii)
- 2.1 Algorithms2.2 Programming fundamentals
- (b)
- 2.1 Algorithms2.2 Programming fundamentals
- (c)(i)
- 2.2 Programming fundamentals2.3 Producing robust programs
- (c)(ii)
- 2.3 Producing robust programs
- (d)
- 2.2 Programming fundamentals
- (e)(i)
- 2.1 Algorithms
Question text
9 Students take part in a sports day. The students are put into teams. Students gain points depending on their result and the year group they are in. The points are added to the team score. The team with the most points at the end of the sports day wins. (a) Data about the teams and students is stored in a sports day program. (i) Identify the most appropriate data type for each variable used by the program. Each data type must be different. Variable Example Data type teamName "Super-Team" studentYearGroup 11 javelinThrow 18.2 [3] (ii) The student names for a team are stored in an array with the identifier theTeam An example of the data in this array is shown: Index 0 1 2 3 4 5 Data Ali Eve Ling Nina Sarah Tom theTeam A linear search function is used to find whether a student is in the team. The function: • takes a student name as a parameter • returns True if the student name is in the array • returns False if the student name is not in the array. Complete the design of an algorithm for the linear search function. function linearSearch(studentName) for count = 0 to if theTeam[ ] == then return endif next count return False endfunction [4] (b) This algorithm calculates the number of points a student gets for the distance they throw in the javelin: 1 javelinThrow = input("Enter distance") 2 yearGroup = input("Enter year group") 3 if javelinThrow >= 20.0 then 4 score = 3 5 elseif javelinThrow >= 10.0 then 6 score = 2 7 else 8 score = 1 9 endif 10 if yearGroup != 11 then 11 score = score * 2 12 endif 13 print("The score is", score) Complete the trace table for the algorithm when a student in year 10 throws a distance of 14.3 You may not need to use all the rows in the table. Line javelinThrow yearGroup score Output [4] (c) The height a student jumps in the high jump needs to be input and validated. The height is entered in centimetres (cm) and must be between 40.0 and 180.0 inclusive. (i) Write an algorithm to: • take the height jumped as input • output "VALID" or "NOT VALID" depending on the height input. You must use either: • OCR Exam Reference Language, or • A high-level programming language that you have studied. [4] (ii) The algorithm is tested using a range of tests. Complete the table to identify an example of test data for each type of test. Test data Type of test Expected output (height jumped in cm) Normal "VALID" Boundary "VALID" Erroneous "NOT VALID" [3] (d) The individual results for each student in each event are stored in a database. The database table TblResult stores the times of students in the 100 m race. Some of the data is shown: StudentID YearGroup TeamName Time 11GC1 11 Valiants 20.3 10VE1 10 Super-Team 19.7 10SM1 10 Super-Team 19.2 11JP2 11 Champions 19.65 Complete the SQL statement to show the Student ID and team name of all students who are in year group 11 SELECT StudentID, FROM [4] (e) Abstraction and decomposition have been used in the design of the sports day program. (i) Identify one way that abstraction has been used in the design of this program. [1] (ii) Identify one way that decomposition has been used in the design of this program. [1] (f) An algorithm works out which team has won (has the highest score). Write an algorithm to: • prompt the user to enter a team name and score, or to enter "stop" to stop entering new teams • repeatedly take team names and scores as input until the user enters "stop" • calculate which team has the highest score • output the team name and score of the winning team in an appropriate message. You must use either: • OCR Exam Reference Language, or • A high-level programming language that you have studied [6]