Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a well-documented (commented) program that computes the fuel efficiency of a multi-leg journey. The program will prompt for the starting odometer reading and then

Write a well-documented (commented) program that computes the fuel efficiency of a multi-leg journey.

The program will prompt for the starting odometer reading and then get information about a series of legs.

For each leg, the user enters the current odometer reading and the amount of gas used.

The user signals the end of the trip by entering -1 for either one of them.

The program should print out the miles per gallon achieved on each leg and the total miles per gallon (MPG) for the trip.

Two sample runs for the program are as follows.

Sample Run 1

Please enter the starting odometer reading: 100 Please enter your odometer reading and gallons of gas used on each leg of the trip. When you have entered data for all the legs, then enter -1 for any of them. Enter odometer reading: 200 Enter gallons used: 5 Enter odometer reading: 400 Enter gallons used: 8 Enter odometer reading: 500 Enter gallons used: -1 The mpg for leg 1 of the journey is: 20.0 The mpg for leg 2 of the journey is: 25.0 The total mpg for this trip is: 23.08

Sample Run 2

Please enter the starting odometer reading: 350 Please enter your odometer reading and gallons of gas used on each leg of the trip. When you have entered data for all the legs then enter -1 for any of them. Enter odometer reading: 500 Enter gallons used: 4 Enter odometer reading: 750 Enter gallons used: 9 Enter odometer reading: -1 Enter gallons used: 6 The mpg for leg 1 of the journey is: 37.5 The mpg for leg 2 of the journey is: 27.78 The total mpg for this trip is: 30.77

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_2

Step: 3

blur-text-image_3

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

Handbook Of Relational Database Design

Authors: Candace C. Fleming, Barbara Von Halle

1st Edition

0201114348, 978-0201114348

More Books

Students also viewed these Databases questions

Question

What led to Karens admission to West Raymond Medical Center?

Answered: 1 week ago

Question

a. When did your ancestors come to the United States?

Answered: 1 week ago

Question

d. What language(s) did they speak?

Answered: 1 week ago

Question

e. What difficulties did they encounter?

Answered: 1 week ago