Clara wants a program to calculate the kinetic energy of a prototype electric vehicle.
Kinetic Energy=0.5×mass×velocity2 \text{Kinetic Energy} = 0.5 \times \text{mass} \times \text{velocity}^2 Kinetic Energy=0.5×mass×velocity2This pseudocode contains the logic required to create the program.
1 # Initialise variables
2
3 SET mass TO 1200
4 SET velocityChk TO TRUE
5
6 # Print prompt and take input from user
7
8 WHILE velocityChk DO
9 SEND "Enter the velocity in m/s (between 1 and 70):" TO DISPLAY
10 RECEIVE velocity FROM (INTEGER) KEYBOARD
11 IF (velocity >= 1 AND velocity <= 70)
12 THEN velocityChk = FALSE
13 END IF
14 END WHILE
15
16 # Calculate and print out values
17
18 SET kineticEnergy TO 0.5 * mass * velocity * velocity
19
20 SEND ("Vehicle mass is: " , mass) TO DISPLAY
21 SEND ("Vehicle velocity is: " , velocity) TO DISPLAY
22 SEND ("Kinetic energy is: " , kineticEnergy) TO DISPLAY
Write a program to implement the logic shown in the pseudocode.
Open Q02a in your integrated development environment (IDE).
You must use the structure given in Q02a to write the program.
Do not add any further functionality.
Save your code as Q02aFINISHED with the correct file extension for your programming language (e.g. .py for Python).