Algorithms

EasyMediumHard
1234567891011121314151617181920212223242526272829303132333435363738
Question 23
Medium

An algorithm is designed to determine electric vehicle (EV) charging rates at a public smart-charging station. The rates are calculated based on the vehicle's remaining battery percentage, the customer's membership tier (where 1 is Bronze, 2 is Silver, and 3 is Gold), and the hour of the day (in 24-hour format).

1  # EV Charging Rate Calculator
2
3  IF (battery_level <= 15) OR (membership_tier = 3) THEN
4      SEND "Priority Eco Rate" TO DISPLAY
5  ELSE
6      IF (hour >= 23) OR (hour < 6) THEN
7          IF membership_tier = 2 THEN
8              SEND "Off-Peak Silver Rate" TO DISPLAY
9          ELSE
10             SEND "Off-Peak Standard Rate" TO DISPLAY
11         END IF
12     ELSE
13         IF (hour >= 11) AND (hour <= 14) THEN
14             SEND "Solar Peak Surcharge" TO DISPLAY
15         ELSE
16             SEND "Standard Day Rate" TO DISPLAY
17         END IF
18     END IF
19  END IF

Complete the table to show the output of the algorithm for each set of inputs.

InputsOutput
battery_level = 45, membership_tier = 3, hour = 12
battery_level = 20, membership_tier = 1, hour = 4
battery_level = 80, membership_tier = 2, hour = 13
[3]

Algorithms Questions

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