212k views
1 vote
Speeding violation calculator design a program that calculates and displays the number of miles per hour over the speed limit that a speeding driver was doing. the program should ask for the speed limit and the driver's speed. validate the input as follows: l the speed limit should be at least 20, but not greater than 70. l the driver's speed should be at least the value entered for the speed limit ( otherwise the driver was not speeding). once correct data has been entered, the program should calculate and display the number of miles per hour over the speed limit that the driver was doing.

1 Answer

5 votes

Module main()

Declare Integer speedLimit, speed, lowSpeed, highSpeed, overSpeed

Set lowSpeed = 20

Set highSpeed = 70

Display “Enter the speed limit.”

Input speedLimit

While speedLimit < lowSpeed OR speedLimit > highSpeed

Display “ERROR: the speed limit must be between, “ lowSpeed,”and”,highSpeed,”.”

Display “Enter the speed limit.”

Input speedLimit

End While

Display “Enter your speed.”

Input speed

Call calcSpeed(speedLimit,speed)

Display “You were going”, overSpeed,”MPH over the speed limit.”

End Module

Module calcSpeed(Integer Ref speedLimit,speed)

Set overSpeed = speedLimit – speed

End Module

User Tinu
by
5.7k points