ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions
14 marks · Data types and structures
Tony wants to store his eight athletes’ data using the record structure shown above. The variable name is athletes. Using pseudocode, or a programming language of your choice, declare the variable which can store the data for the eight athletes. Using pseudocode, or a programming language of your choice, write the code necessary to add the data for the athlete Salma shown in the table above. Your answer should use the variable declared in part (a). Tony wants to find the fastest 400 m time of the season. Using pseudocode, or a programming language of your choice, design an algorithm to find the fastest season time. Your answer should use the variable declared in part (a). Tony has added the following to his program. Line 1 CREATE “C:\MyAthletes\winner.txt” Line 2 SEND fastest TO “C:\MyAthletes\winner.txt” Line 3 CLOSE “C:\MyAthletes\winner.txt” Describe the purpose of line 1. Describe the purpose of line 2. Tony runs his program but the program produces the wrong output when compared with his test data. Other than a trace table, name and describe a technique that Tony could use to locate and identify the error. Tony coaches a team of eight elite athletes for a 400 metre race. Tony uses a program to help analyse each athlete’s performance. A sample of the data held on each athlete is shown below. Athlete Data Forename Salma Surname Hussain Runner number 324 Professional True Season best 45·12 Weight (kg) 67·5 Tony has added a record structure to his program. RECORD athleteData IS {STRING forename, STRING surname, INTEGER runnerNumber, BOOLEAN professional, REAL seasonBest, REAL weight}
DECLARE athletes[7] As athleteData 1 mark for data type as athleteData 1 mark for an array of 8 values assigned to variable athletes DECLARE athletes[] INITIALLY athleteData (“Salma”, “Hussain”, 324, True, 45.12, 67·5) OR SET athletes[] TO athleteData (“Salma”, “Hussain”, 324, True, 45.12, 67·5) OR athletes().forename = “Salma” athletes().surname = “Hussain” athletes().runnerNumber = 324 athletes().professional = True athletes().seasonBest = 45.12 athletes().weight = 67.5 1 mark for use of array eg. athletes() (accept appropriate name or name candidate declared in (a)) 1 mark for use of athleteData as a data type NOT a variable 1 mark for correct values in correct order or values related to the field name Accept answers in a high level language or pseudocode • Array eg. athletes() • Field Names eg. .forename • Assignment of value Line 1 SET minimum TO athletes[0].seasonBest Line 2 FOR counter FROM 1 TO 7 DO Line 3 IF athletes[counter].seasonBe st < minimum THEN Line 4 minimum = athletes[counter].seasonBe st Line 5 END IF Line 6 END FOR For five marks: • 1 mark for assignment of minimum before loop • 1 mark for use of seasonBest as a field to access record at least once • 1 mark for correct If construct with correct condition (with end if or indentation) • 1 mark for assignment of minimum using the array() • 1 mark for correct loop construct (with end loop or indentation) Allow indexing from 1 or 0 To create a file called ‘winner’ inside the folder MyAthletes on the C drive 1 mark for creating a file To write the fastest time to the file called winner.txt 1 mark for writing to file (accept sending) 1st mark for naming a technique: • Dry Run • Breakpoint 2nd mark for related description Dry Run Manual run through of code often involving a pen and paper to try to identify errors Breakpoint • Stop the program OR • Inspect the value of variables
Previous question: Higher Computing Science 2016 Question 14 (CfE)
Next question: Higher Computing Science 2017 Question 1 (CfE)