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!” Notice that the expression on the right side of the formula above will force the compiler to convert everything to type double. Use type double for your working variables. Write your program so that it is able to produce the following screen display: Sample session: Enter your speed (in mph): 60.0 Enter your tailgate distance (in feet): 240.0 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!”
Notice that the expression on the right side of the formula above will force the
compiler to convert everything to type double. Use type double for your working
variables. Write your program so that it is able to produce the following screen
display:
Sample session:
Enter your speed (in mph): 60.0
Enter your tailgate distance (in feet): 240.0
Major wreck!
As the programming language is not mentioned here, we are using JAVA
The JAVA code is given below with code and output screenshot.
Happy to help you ?
Step by step
Solved in 4 steps with 3 images