Question: Suppose you are asked to write a C++ program to evaluate the fuel consumption of a car. Have the user input the number on the
Suppose you are asked to write a C++ program to evaluate the fuel consumption of a car. Have the user input the number on the car's odometer reading in KM at the start and end of the journey, and also the fuel level in the tank (in liter) at the start and end of the journey. Calculate fuel used, KM travelled, and the overall fuel consumption in KM travelled per Liter of fuel. Print these values, accompanied by appropriate messages indicating what they are. Answer the following questions: (a) Determine the input(s) and output(s) required by the program. (b) What is the formula for converting the input items into output items? (c) Provide a solution algorithm for this problem. (d) How would you verify the validity of the program output? (e) Write the complete program to test the algorithm designed. Sample program output as follow: Enter the KM on your car's odometer at the start of your journey 20 Enter the fuel level (Liter) in your tank at the start of your journey 19.5 Enter the KM on your car's odometer at the end of your journey 88 Enter the fuel level (Liter) in your tank at the end of your journey 17.6 You traveled 68 KM using 1.9 Liter of fuel Your fuel consumption was 35.7895 KM per Liter
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
