Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

using C++, please.. Write a program to evaluate the fuel efficiency of a car. The mileage at the start and end of the journey should

using C++, please..

Write a program to evaluate the fuel efficiency of a car. The mileage at the start and end of the journey should be read, and also the fuel level in the tank at the start and end of the journey. Calculate fuel used, miles traveled, and hence the overall fuel consumption in miles traveled per gallon of fuel.

In many countries using the metric system, car fuel consumptions are measured in liters of fuel required to travel 100 kilometers. Modify your solution so that the output now specifies the distance traveled in kilometers as well as in miles, and the fuel consumed in liters as well as in gallons, and the consumption in liters per 100 kilometers as well as in miles per gallon. Use const variables declared inside of main() for the conversion factors between miles and kilometers, and gallons and liters.( 1 mile = 1.609 km, and 1 U.S. gallon = 3.785 liters.)

Before you do any coding I recommend first writing an algorithm for 7 below, and then testing this algorithm with the values in the image assignment2.jpg.

Algorithm (simplified)

1. Prompt for the starting mileage in miles, then get the starting mileage from standard input.

2. Prompt for the ending mileage in miles, then get the ending mileage from standard input.

3. Prompt for the starting fuel level in U.S. gallons, then get the starting fuel level from standard input.

4. Prompt for the ending fuel level in U.S. gallons, then get the ending fuel level from standard input.

5. Calculate output variables.

6. Using U.S. units, output distance traveled, fuel consumption, and miles per gallon.

7. Using metric units, output distance traveled, fuel consumption, and liters per 100 km. See the sample program run image for details..

Program template:

Copy the code below and fill in the blanks. Write comments at the top of your code as laid out below. In these comments at the top, do not use semicolons. Your goal is to make your comments applicable to any programming language, and semicolons are language-specific. For the Summary section, write what the program does and the key restrictions and limitations it must work within. In the Variables section, describe three things: each variables data type, identifier name (i.e., the same variable name which will be used later on in the program), and purpose. The Equations section can be in pseudocode or English. It is not necessary to document changing a variable by 1 in the Equations section, but it does make sense to write down important logic equations there. If your program is complicated and needs more documentation about algorithms or how the program operates, write about it after of the Equations section.

/*CS 161 Assignment 2

Filename: a02.cpp

Author: ___

Date: ___

Summary:

Variables:

___

Equations:

___

*/

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction To Data Mining

Authors: Pang Ning Tan, Michael Steinbach, Vipin Kumar

1st Edition

321321367, 978-0321321367

More Books

Students also viewed these Databases questions

Question

2 The main characteristics of the market system.

Answered: 1 week ago