Skip to content
MathsGenie logo
Open app

Course home

  1. IGCSE
  2. Computer Science Edexcel
  3. Question bank

Develop code

EasyMediumHard
123456789101112131415161718192021222324252627
Question 14

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×velocity2

This 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).

[10]

Develop code Questions

  1. IGCSE
  2. /Computer Science
  3. /Develop code