Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 13
Medium

An algorithm is used to calculate the rental price of an electric bicycle based on the number of hours rented.

10 SEND "Welcome to E-Bike Rentals" TO DISPLAY
11 SEND "How many hours do you want to rent?" TO DISPLAY
12 RECEIVE hours FROM (INTEGER) KEYBOARD
13 SEND "Pricing for " & hours & " hour(s)" TO DISPLAY
14
15 IF (hours > 8) THEN
16     SET price TO 40 + (5 * (hours - 8))
17 ELSE
18     IF (hours > 5) THEN
19         SET price TO 40
20     ELSE
21         IF (hours > 2) THEN
22             SET price TO 30
23         ELSE
24             SET price TO 15
25         END IF
26     END IF
27 END IF
28
29 SEND "Total: £" & price TO DISPLAY

Complete the table to show the final output displayed by line 29 of the algorithm for each given input.

InputOutput
10
1
6
[3]

Algorithms Questions

  1. GCSE
  2. /Computer Science
  3. /Algorithms