Advertisement
akosiraff

Project6 1, 2 & 3 C/C++ Answer

Apr 30th, 2017
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.72 KB | None | 0 0
  1.  
  2. Download: https://solutionzip.com/downloads/project6-1-2-3/
  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:
  4. stoppingDistance = speed * (2.25 + speed / 21)
  5. 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.
  6. 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!”
  7. Sample session:
  8. Enter your speed (in mph): 60.0
  9. Enter your tailgate distance (in feet): 240.0 Major wreck!
  10. 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.
  11. c) Allow the user to enter the speed in kmph or mph and the distance in the corresponding unit (m or feet).
  12. 2. Write a program to mimic a unit converter
  13. The program should permit the user to keep going or terminate after each calculation is made.
  14. Download: https://solutionzip.com/downloads/project6-1-2-3/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement