# Aircraft Fuel Calculator # This program uses input from the user to calculate flight time and required fuel #print program heading print ("Aircraft Fuel Calculator") print () #import math to use ceil function import math #roundup function to always round up the number def roundup (Required_fuel, digits=0) : n = 10**-digits return round (math.ceil (Required_fuel / n) * n, digits) #Initialize variable Continue with character 'y' Continue='y' #while loop for repetition while (Continue=='y') : #input nautical miles from the user nautical miles=int (input ("Distance in nautical miles: ")) #calculate hour hour= int (nautical miles/120) #calculate remaining minutes minute=int (nautical miles%120) #calculate actual minutes minutes=int ( (minute/l20) *60) #print Flight time print ("Flight time: ",hour, "hour and",minutes, "minute (s) ") #initialize safety value safety=30 #calculate Required_fuel Required_fuel=(8.4*hour)+ (( (minutes+safety) *8.4)/60) #print Required_fuel print ("Required fuel: ",roundup (Required_fuel, 1),"gallons") print () #input y or n from user Continue=input ("Continue? (y/n): ") print () #exít message t o user print () print ("Bye!")

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
icon
Concept explainers
Question

How could I change the attached Python program, so that I can:

1.  input my beginning fuel (in gallons)

2.  input the name of each destination

2.  input each of multiple flight distances

3.  receive a warning when I reach the flight that will run out of fuel

The current, very basic fuel calculator is attached.

# Aircraft Fuel Calculator
# This program uses input from the user to calculate flight time and required fuel
#print program heading
print ("Aircraft Fuel Calculator")
print ()
#import math to use ceil function
import math
#roundup function to always round up the number
def roundup (Required_fuel, digits=0) :
n = 10**-digits
return round (math.ceil (Required_fuel / n) * n, digits)
#Initialize variable Continue with character 'y'
Continue='y'
#while loop for repetition
while (Continue=='y') :
#input nautical miles from the user
nautical miles=int (input ("Distance in nautical miles: "))
#calculate hour
hour= int (nautical miles/120)
#calculate remaining minutes
minute=int (nautical miles%120)
#calculate actual minutes
minutes=int ( (minute/l20) *60)
#print Flight time
print ("Flight time: ",hour, "hour and",minutes, "minute (s) ")
#initialize safety value
safety=30
#calculate Required_fuel
Required_fuel=(8.4*hour)+ (( (minutes+safety) *8.4)/60)
#print Required_fuel
print ("Required fuel:
",roundup (Required_fuel, 1),"gallons")
print ()
#input y or n from user
Continue=input ("Continue? (y/n): ")
print ()
#exít message t o user
print ()
print ("Bye!")
Transcribed Image Text:# Aircraft Fuel Calculator # This program uses input from the user to calculate flight time and required fuel #print program heading print ("Aircraft Fuel Calculator") print () #import math to use ceil function import math #roundup function to always round up the number def roundup (Required_fuel, digits=0) : n = 10**-digits return round (math.ceil (Required_fuel / n) * n, digits) #Initialize variable Continue with character 'y' Continue='y' #while loop for repetition while (Continue=='y') : #input nautical miles from the user nautical miles=int (input ("Distance in nautical miles: ")) #calculate hour hour= int (nautical miles/120) #calculate remaining minutes minute=int (nautical miles%120) #calculate actual minutes minutes=int ( (minute/l20) *60) #print Flight time print ("Flight time: ",hour, "hour and",minutes, "minute (s) ") #initialize safety value safety=30 #calculate Required_fuel Required_fuel=(8.4*hour)+ (( (minutes+safety) *8.4)/60) #print Required_fuel print ("Required fuel: ",roundup (Required_fuel, 1),"gallons") print () #input y or n from user Continue=input ("Continue? (y/n): ") print () #exít message t o user print () print ("Bye!")
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Knowledge Booster
Operators
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education