The diving competitions at the gala will be scored by five judges - Edexcel - GCSE Computer Science - Question 9 - 2021 - Paper 1
Question 9
The diving competitions at the gala will be scored by five judges. Each judge awards each dive a score between 0.0 and 10.0. The highest and lowest of the judges' sc... show full transcript
Worked Solution & Example Answer:The diving competitions at the gala will be scored by five judges - Edexcel - GCSE Computer Science - Question 9 - 2021 - Paper 1
Step 1
ARRAY scores
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Define an array scores with the given values:
ARRAY scores
SET scores TO [8.9, 9.1, 8.2, 7.8, 8.1]
Step 2
REAL inFactor
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Declare a variable inFactor to hold the degree of difficulty factor:
REAL inFactor
Step 3
Find highest and lowest scores
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Initialize variables to hold the highest and lowest scores:
REAL highest = 10.0
REAL lowest = 0.0
Step 4
Loop through scores
98%
120 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Use a loop to find the highest and lowest scores:
FOR index FROM 1 TO LENGTH(scores) DO
IF scores[index] < lowest THEN
lowest = scores[index]
END IF
IF scores[index] > highest THEN
highest = scores[index]
END IF
END FOR
Step 5
Calculate total score
97%
117 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Compute the total of the remaining scores:
REAL total = 0
FOR index FROM 1 TO LENGTH(scores) DO
IF scores[index] != highest AND scores[index] != lowest THEN
total = total + scores[index]
END IF
END FOR
Step 6
Calculate dive score
97%
121 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Calculate the final dive score:
REAL diveScore = total * inFactor
DISPLAY diveScore