stoppingDistance = speed * (2.25 + speed / 21) Write a program which determines whether a vehicle’s tailgating distance is safe. The program should read in the speed of the vehicle and the vehicle’s tailgating distance. The program should then calculate the distance that would be required to stop the vehicle. If the stopping distance is less than the tailgating distance, your program should print “No problem.” If the stopping distance equals the tailgating distance, your program should print “Minor wreck.” If the stopping distance is greater than the tailgating distance, your program should print “Major wreck!”
Max Function
Statistical function is of many categories. One of them is a MAX function. The MAX function returns the largest value from the list of arguments passed to it. MAX function always ignores the empty cells when performing the calculation.
Power Function
A power function is a type of single-term function. Its definition states that it is a variable containing a base value raised to a constant value acting as an exponent. This variable may also have a coefficient. For instance, the area of a circle can be given as:
stoppingDistance = speed * (2.25 + speed / 21)
Write a
The program should read in the speed of the vehicle and the vehicle’s tailgating
distance. The program should then calculate the distance that would be required to
stop the vehicle.
If the stopping distance is less than the tailgating distance, your program
should print “No problem.” If the stopping distance equals the tailgating
distance, your program should print “Minor wreck.” If the stopping distance
is greater than the tailgating distance, your program should print “Major
wreck!”
Step-1: Start
Step-2: Declare variables speed, dist, stoppingDistance
Step-3: Take input for speed and dist from user
Step-4: Convert speed mph to fph
Step-5: Initialize stoppingDistance with speed * (2.25 + speed / 21)
Step-6: If stoppingDistance is less than dist, print "No problem."
Step-7: Otherwise, if stoppingDistance is equal to dist, print "Minor wreck."
Step-8: Otherwise, print "Major wreck!"
Step-9: Stop
Step by step
Solved in 4 steps with 3 images