Project6 1, 2 & 3

If you follow too close behind another car and that other car stops suddenly, you will not be able to stop in time, and you will crash into the rear of that other car. The following formula gives the distance between you and the car in front which allows you to stop safely:
stoppingDistance = speed * (2.25 + speed / 21)
a) 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!”
Sample session:
Enter your speed (in mph): 60.0
Enter your tailgate distance (in feet): 240.0 Major wreck!
b) Notice that one of the tests is a comparison for equality. Since the probability of two real numbers being exactly equal is zero, if you use floating point numbers there will never be an input that produces a minor wreck. Modify the program so that it allows a range of uncertainty entered by the user, within which the result will be a minor wreck.
c) Allow the user to enter the speed in kmph or mph and the distance in the corresponding unit (m or feet).
2. Write a program to mimic a unit converter
The program should permit the user to keep going or terminate after each calculation is made.

New Download