83Medium
0/3

An algorithm is designed to determine electric vehicle (EV) charging rate categories based on the vehicle's battery capacity (in kWh), the day of the week (where 1 is Monday and 7 is Sunday), and the hour of the day (in 24-hour format).

1  # EV charger rate calculator
2
3  IF (capacity < 20) OR (capacity >= 100) THEN
4      SEND "Specialist Rate" TO DISPLAY
5  ELSE
6      IF (day = 6) OR (day = 7) THEN
7          IF hour >= 18 THEN
8              SEND "Peak Weekend Rate" TO DISPLAY
9          ELSE
10             SEND "Standard Weekend Rate" TO DISPLAY
11         END IF
12     ELSE
13         IF (hour >= 7) AND (hour <= 10) THEN
14             SEND "Peak Weekday Rate" TO DISPLAY
15         ELSE
16             SEND "Off-Peak Weekday 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
capacity = 15, day = 6, hour = 19
capacity = 50, day = 7, hour = 14
capacity = 75, day = 3, hour = 9
[3]

Algorithms Questions

Practise Edexcel GCSE Computer Science Algorithms with exam-style questions for GCSE Computer Science. 100 questions covering Constructs for solving problems, Variables, constants and data structures, Arithmetic, relational and logical operators, Tracing algorithm output with trace tables, Types of error and correcting logic errors, Standard algorithms (sorts and searches), and Evaluating algorithm fitness and efficiency, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.

PreviousNext

Algorithms Questions

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