1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Pepsi [2]
3 years ago
10

Drivers are concerned with the mileage obtained by their automobiles. One driver has kept track of several tankfuls of gasoline

by recording miles driven and gallons used for each tankful. Develop a sentinel-controlled-repetition script that prompts the user to input the miles driven and gallons used for each tankful. The script should calculate and display the miles per gallon obtained for each tankful. After processing all input information, the script should calculate and display the combined miles per gallon obtained for all tankfuls (that is, total miles driven divided by total gallons used).
Enter the gallons used (-1 to end): 128
Enter the miles driven: 287 The miles/gallon for this tank was 22.421875
Enter the gallons used (-1 to end): 10.3
Enter the miles driven: 200 The miles/gallon for this tank was 19.417475
Enter the gallons used (-1 to end): 5
Enter the miles driven: 120 The miles/gallon for this tank was 24.000000
Enter the gallons used (-1 to end): -1 The overall average miles/gallon was 21. 601423
Computers and Technology
1 answer:
iVinArrow [24]3 years ago
4 0

Answer:

In Python:

gals= float(input("Enter the gallons used (-1 to end): "))

miles = float(input("Enter the miles driven: "))

mileage = 0.0

count = 0

while not (gals == -1):

   count += 1

   mileage +=(miles/gals)

   print("The miles/gallon for this tank was "+str(round(miles/gals,6)))

   gals= float(input("Enter the gallons used (-1 to end): "))

   miles = float(input("Enter the miles driven: "))

print("The overall average miles/gallon was "+str(round(mileage/count,6)))

Explanation:

#This prompts the user for the number of gallons used

gals= float(input("Enter the gallons used (-1 to end): "))

#This prompts the user for miles driven

miles = float(input("Miles driven: "))

#This initializes the mileage to 0

mileage = 0.0

#This initializes the count of vehicles to 0

count = 0

#The following is repeated until input for gallons is -1

while not (gals == -1):

#The count of vehicles is increased by 1

   count += 1

#The total mileage for all cars is calculated

   mileage +=(miles/gals)

#This prints the mileage for that particular vehicle

   print("The miles/gallon for this tank was "+str(round(miles/gals,6)))

#This prompts the user for the number of gallons used

   gals= float(input("Enter the gallons used (-1 to end): "))

#This prompts the user for miles driven

   miles = float(input("Miles driven: "))

#This calculates and prints the overall average mileage  

print("The overall average miles/gallon was "+str(round(mileage/count,6)))

You might be interested in
In a nested repetition structure, one loop, referred to as the ____ loop, is placed entirely within another loop, called the ___
Alja [10]

Answer:

Inner, outer

Explanation:

Bruh. Its logic

3 0
3 years ago
If a device does not require a driver, it is _____.
xxTIMURxx [149]

Answer:

(B) plug and play

Explanation:

If a device does not require a driver, it is <u>plug and play</u>. Plug and Play (PnP) is a combination of hardware and software support that enables a computer system to recognize and adapt to hardware configuration changes with little or no intervention by a user, including the loading of appropriate drivers.

7 0
4 years ago
what are some steps Hector could have taken to ensure that his photographs were not ruined near the end of the shoot?
galben [10]

Answer:

make several extra copies of the pictures and frame them right away if they're printed out.

Explanation:

3 0
2 years ago
Your essay is due tomorrow and you don't have time to write it. You decide to buy an essay online. You've paid for it, so it can
viva [34]

Answer:

false

even though you have paid for it , you still didn't write it by yourself, there for it will still be seen as plagiarism.......hope this helps

4 0
3 years ago
Which programming term describes the various characteristics of an object, such as its size and color?
SashulF [63]

Answer:

A

Explanation:

6 0
4 years ago
Other questions:
  • Google wallet software utilizes android phones with near field communication technology, such as _____, to allow shoppers to swi
    12·1 answer
  • In the 2000s, Venezuelan President Hugo Chàvez instituted economic policies that caused smuggling and hoarding of food. What did
    15·1 answer
  • 1. How do you answer questions that require you to draw inferences? (1 point)
    7·2 answers
  • What are the three major functions of a game engine?
    15·1 answer
  • int sequence[10] = { 3, 4, 5, 6, 7, 8, 9, 10, 1, 2 }; Write a C++ program to ask the user to enter a number, if the number can b
    10·1 answer
  • The _______ of a secondary storage device indicates how much data the storage medium can hold.
    13·1 answer
  • If you Owned a business, what part of Microsoft Office would you use the most and why, which would you use the least and why, an
    14·1 answer
  • Which componet is the smallest unit in a spreadsheet
    15·1 answer
  • How can one create an online professional network using Face book?
    14·1 answer
  • Which document outlines the activities carried out during testing?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!