Sam is thinking about driving from his town to another location by car, but he is unsure how much time he should allow based on the distance and speed. It is important to note that some routes use miles while others use kilometers. To assist Sam, you can use the formula: Time = Distance/Speed and provide him with the time in minutes. Write a C++ program that prompts Sam to enter the distance in either Miles or Kilometers followed by the average speed in kilometers/minute. If Sam enters the distance in Miles, you should convert it to Kilometers, with 1 mile equaling 1.6 kilometers. Your program should accept only positive numbers for distance and speed values. Once you have found the time, you should check the safety of the car systems by asking four questions: What is the Oil level on the dipstick, enter 0 for below minimum, 1 for between minimum and maximum and 2 above maximum? Is the front and rear Tires Pressures between 30 and 35? Answer Yes or No Is the engine temperature warning light ON? Answer Yes or No Is the Battery Alert light ON? Answer Yes or No First, print the time and the speed with the distance in three decimal places. Then, based on Sam's answers, display the safety actions. If Sam answers 1 for question 1, “Yes” for question 2 and "No" to all other questions, show a message that reflects this. However, if Sam answers 0 or 2 for the first question, “No” for the second question or "Yes" to any other questions, display a formatted table showing the corresponding action Sam should take. Refer to the table below for the appropriate action for each safety question.
-
Sam is thinking about driving from his town to another location by car, but he is unsure how much time he should allow based on the distance and speed. It is important to note that some routes use miles while others use kilometers. To assist Sam, you can use the formula: Time = Distance/Speed and provide him with the time in minutes.
Write a C++ program that prompts Sam to enter the distance in either Miles or Kilometers followed by the average speed in kilometers/minute. If Sam enters the distance in Miles, you should convert it to Kilometers, with 1 mile equaling 1.6 kilometers. Your program should accept only positive numbers for distance and speed values. Once you have found the time, you should check the safety of the car systems by asking four questions:
-
What is the Oil level on the dipstick, enter 0 for below minimum, 1 for between minimum and maximum and 2 above maximum?
-
Is the front and rear Tires Pressures between 30 and 35? Answer Yes or No
-
Is the engine temperature warning light ON? Answer Yes or No
-
Is the Battery Alert light ON? Answer Yes or No
First, print the time and the speed with the distance in three decimal places. Then, based on Sam's answers, display the safety actions. If Sam answers 1 for question 1, “Yes” for question 2 and "No" to all other questions, show a message that reflects this. However, if Sam answers 0 or 2 for the first question, “No” for the second question or "Yes" to any other questions, display a formatted table showing the
-
corresponding action Sam should take. Refer to the table below for the appropriate action for each safety question.
Cause:
Oil level below minimum
Oil level above maximum
Tires Pressures is not between 30 and 35
Engine temperature warning light ON
Battery Alert light ON
Action:
You should add oil as needed and inspect for any potential oil leaks.
You should visit a repair shop to drain the excess oil
Check the tire pressure and adjust it as needed by inflating or deflating the tires.
Call a roadside service to tow your car to a repair shop.
You should visit a repair shop to have your electrical system checked for faults. A new battery may be necessary.
Step by step
Solved in 4 steps with 3 images