Q.Write a pseudocode for creating a scoreboard for a hockey match.
You're viewing a preview — the full solution, concept, methods & PYQ mapping are locked.
Start your 14-day free trial to unlock the full solution →A live scoreboard = two accumulator variables (goalsA, goalsB) + a loop that runs for the duration of the match: each scoring event increments one counter and the updated score is displayed immediately; at full time the counters are compared.
The idea. This activity combines all three control structures: sequence (initialise, then loop, then declare result), repetition (the match loop, which ends on a sentinel — full time), and selection (which team's counter to increment, and who won). It is the same accumulator pattern as the averaging examples, just with two counters.
Pseudocode:
Step 1: SET goalsA = 0, goalsB = 0
Step 2: DISPLAY "HOCKEY SCOREBOARD Team A: 0 Team B: 0"
Step 3: WHILE the match is not over, REPEAT Steps 4-6
Step 4: INPUT event // "A" = Team A scored, "B" = Team B scored,
// "end" = full time
Step 5: IF event == "A" THEN goalsA = goalsA + 1
ELSE IF event == "B" THEN goalsB = goalsB + 1
Step 6: DISPLAY "Team A:", goalsA, " Team B:", goalsB
Step 7: IF goalsA > goalsB THEN DISPLAY "Team A wins"
ELSE IF goalsB > goalsA THEN DISPLAY "Team B wins"
ELSE DISPLAY "Match drawn"
Python implementation (event-driven simulation):
goalsA = goalsB = 0
print("HOCKEY SCOREBOARD Team A: 0 Team B: 0")
while True:
event = input("Who scored? (A/B, or 'end' for full time): ")
if event == "end":
break
if event == "A":
goalsA += 1
elif event == "B":
goalsB += 1
print("Team A:", goalsA, " Team B:", goalsB)
if goalsA > goalsB:
print("Team A wins")
elif goalsB > goalsA:
print("Team B wins")
else:
print("Match drawn")
``` …
Unlock everything free for 14 days
- Full step-by-step solutions
- Concept-first explanations
- Methods, shortcuts & mistakes
- PYQ mapping + timed mock tests
Full access for 14 days. No credit card required.