Loop (Unconditional)

icon picker
Bus Pass

Debug task: can you find and fix the errors

example requirement

Display bus passes for students travelling to school. The bus pass should show the route, pickup point and bus pass number. The program should allow the user to enter the route and a the required number of bus passes, one for each pick up point. The user should then be able to enter a list of pick up points.

example ticket design and user interface

Which bus route are you going on
West Calder
How many bus passes:
2
Enter pickup point
Post Office
- - - - - - - - - - - - - - -
Student Bus Pass
Bus Route: West Calder
Pickup Point: Post Office
Bus Pass number: 1
- - - - - - - - - - - - - - -

Enter pickup point
Health Centre
- - - - - - - - - - - - - - -
Student Bus Pass
Bus Route: West Calder
Pickup Point: Health Centre
Bus Pass number: 2
- - - - - - - - - - - - - - -

example design

prompt for the route name
enter the route name

prompt for the number of bus passes
enter the number of bus passes

loop for number of bus passes with index
prompt for the pick up point
enter the pick up point

display the ticket design
display the route name
display the pick up point
display the bus pass number
end loop

developer task

Read the requirement, sample output and design.
Run the example code in the program. Read the error messages.
Try to locate and fix the bugs, there are more than one!
Read the code. Try to recognise the names, types and values for each variable.
Identify the for-loop control structure.

program code

Loading…

Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.