Step 4 - Calculating speed
Next, let’s calculate the current average speed.
-
New variables and constants?
We will need to store the speed. We can calculate this as
distance
divided by,time
divided by 60. Where 60 represents minutes per hour.We can track the speed by adding a
speed
variable, but we should also add aMINUTES_PER_HOUR
constant to make this meaningful in our code. -
Add the code to calculate the speed and output the speed.
-
-
Compile and run your program. Check the output matches what we are after.