Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112131415161718192021222324
Question 20

Liam has written a pseudocode algorithm to track gym activities and calculate points. If a member does swimming, they get 5 points. If they do cycling, they get 12 points.

The algorithm should output the total points, the number of swimming sessions, and the number of cycling sessions.

However, there is an error in the algorithm.

1 SET Activity TO ""
2 SET TotalPoints TO 0
3 SET SwimPoints TO 0
4 SET CyclePoints TO 0
5 SET SwimSessions TO 0
6 SET CycleSessions TO 0
7
8 WHILE Activity <> "-1" DO
9     RECEIVE Activity FROM (STRING) KEYBOARD
10    IF Activity = "swimming" THEN
11        SET SwimPoints TO SwimPoints + 5
12        SET SwimSessions TO SwimSessions + 1
13    ELSE
14        IF Activity = "cycling" THEN
15            SET CyclePoints TO CyclePoints + 12
16            SET CycleSessions TO CycleSessions + 1
17        END IF
18    END IF
19 END WHILE
20
21 SET TotalPoints TO SwimPoints + CyclePoints
22
23 SEND ("Total Points: " & TotalPoints) TO DISPLAY
24 SEND ("Swimming Sessions: " & SwimSessions) TO DISPLAY
25 SEND ("Cycling Sessions: " & CyclePoints) TO DISPLAY

Write a replacement for line 25 of the pseudocode to correct the error.

[1]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code