General Foo’s Last Chance Gas station sits on route 190 on the edge of Death Valley. There is no other gas station for 200 miles. You are to write a Python program to help drivers if they need gas. The program asks for user input: • Vehicle Name, any name is valid (e.g. Toyota, Mercedes, Ford, GM, Chrysler, Nissan, Kia, Honda, etc.) • Vehicle Type: valid types are C: Car , S: SUV or T: Truck (note lower case letters are also allowed, e.g. c, s, or t; all others are invalid). If a user enters incorrect type, a message to that effect should be printed and no other information printed • The capacity of the gas tank, in gallons • The indication of the gas gauge in percent (full=100, three-quarters full=75, and so on, empty=0) Assume that a car’s gas mileage is 32 miles per gallon, a SUV’s gas mileage is 25 miles per gallon and a truck’s mileage is 15 miles per gallon. Depending upon user input, your program prints a message to either put a minimum amount of gas in the vehicle or “Safe to Proceed” depending on whether the vehicle can cross the 200 miles stretch of Death Valley with the gas remaining in the tank. Furthermore, your program should calculate the amount of gas needed based on the input rather than hard-coding values. Stages of the Program program gathers input data for ONE car (without validating it), calculates how much gas the car’s driver will need, and print it. (see below for exact format). AFTER STAGE 1 WORKS CORRECTLY add data validation (see rules below) for the input gathering. AFTER STAGE 2 WORKS CORRECTLY add looping so that the program can handle as many cars as the user provides. After handling one car, the program asks whether the user wants to enter data for another car then proceeds accordingly). (STAGE 3 VERSION OF THE PROGRAM IS THE ONE THAT YOU SHOULD SUBMIT TO GET THE FULL 100 POINTS). Input (for 1 car) Use input() function with appropriate prompts to get the following information from the user: vehicle name, vehicle type, tank capacity, and gauge reading. Variable Naming Use appropriate variable names, following the Python Naming Conventions. Input Validation (added in stage 2) • Car types values can ONLY be one of: C,S, T (or c, s, t). o Before checking for validity, do 2 things to “help the user” by fixing certain things: o Grab just the 0th char they entered (in case they type in Low) char0 = input_str[0]. o Capitalize that first char (in case they entered a) cap_char = char0.upper(). o If it’s invalid, keep asking the user for a valid tier letter until they enter something correct. o Each of the 3 car types will have its own validation loop. • Tank capacity must be a positive number (integer) that’s > 0 o If it’s invalid, keep asking the user for a valid tank capacity until they enter something correct. • Gauge reading indicator must be a positive number (integer that is 100 <= Gauge reading <=0) o If it’s invalid, keep asking the user for a valid gauge reader until they enter something correct. Input -Multiple Cars (added in stage 3) • After printing the report for a single car, ask the user if they wish to enter another car (YES or NO). o If they say YES (or Yes or yes or YEs or yeS or …) or Y (or y), then go around the big loop again.  Use the 2 String methods to 1) grab just the 1st char and 2) capitalize it) to reduce the number of cases that need to be checked to just ‘Y’ (so that’d include yup, yea, yo, yellow, . . .) o Any other response (like No/no/N/n/nope/naw/whatever/who cares/red/green/…) will be assumed to be a NO. Program Control Structures Use if-else, if-elif … to determine the amount of gas needed for each car type entered by the user. Deliverables The deliverable for this project is the following file: proj02_LastName.py Be sure to use the specified file name and to submit it for grading via Codio before the project deadline.

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
Question

Python***

General Foo’s Last Chance Gas station sits on route 190 on the edge of Death Valley. There is no other gas station for 200 miles. You are to write a Python program to help drivers if they need gas. The program asks for user input:
• Vehicle Name, any name is valid (e.g. Toyota, Mercedes, Ford, GM, Chrysler, Nissan, Kia, Honda, etc.)
• Vehicle Type: valid types are C: Car , S: SUV or T: Truck (note lower case letters are also allowed, e.g. c, s, or t; all others are invalid). If a user enters incorrect type, a message to that effect should be printed and no other information printed
• The capacity of the gas tank, in gallons
• The indication of the gas gauge in percent (full=100, three-quarters full=75, and so on, empty=0)
Assume that a car’s gas mileage is 32 miles per gallon, a SUV’s gas mileage is 25 miles per gallon and a truck’s mileage is 15 miles per gallon. Depending upon user input, your program prints a message to either put a minimum amount of gas in the vehicle or “Safe to Proceed” depending on whether the vehicle can cross the 200 miles stretch of Death Valley with the gas remaining in the tank. Furthermore, your program should calculate the amount of gas needed based on the input rather than hard-coding values.

Stages of the Program

  1. program gathers input data for ONE car (without validating it), calculates how much gas the car’s driver will need, and print it. (see below for exact format).
  2. AFTER STAGE 1 WORKS CORRECTLY add data validation (see rules below) for the input gathering.
  3. AFTER STAGE 2 WORKS CORRECTLY add looping so that the program can handle as many cars as the user provides. After handling one car, the program asks whether the user wants to enter data for another car then proceeds accordingly). (STAGE 3 VERSION OF THE PROGRAM IS THE ONE THAT YOU SHOULD SUBMIT TO GET THE FULL 100 POINTS).

Input (for 1 car)

Use input() function with appropriate prompts to get the following information from the user: vehicle name, vehicle type, tank capacity, and gauge reading.

Variable Naming

Use appropriate variable names, following the Python Naming Conventions.

Input Validation (added in stage 2)

• Car types values can ONLY be one of: C,S, T (or c, s, t).
o Before checking for validity, do 2 things to “help the user” by fixing certain things:
o Grab just the 0th char they entered (in case they type in Low) char0 = input_str[0].
o Capitalize that first char (in case they entered a) cap_char = char0.upper().
o If it’s invalid, keep asking the user for a valid tier letter until they enter something correct.
o Each of the 3 car types will have its own validation loop.
• Tank capacity must be a positive number (integer) that’s > 0
o If it’s invalid, keep asking the user for a valid tank capacity until they enter something correct.
• Gauge reading indicator must be a positive number (integer that is 100 <= Gauge reading <=0)
o If it’s invalid, keep asking the user for a valid gauge reader until they enter something correct.

Input -Multiple Cars (added in stage 3)

• After printing the report for a single car, ask the user if they wish to enter another car (YES or NO).
o If they say YES (or Yes or yes or YEs or yeS or …) or Y (or y), then go around the big loop again.
 Use the 2 String methods to 1) grab just the 1st char and 2) capitalize it) to reduce the number of cases that need to be checked to just ‘Y’ (so that’d include yup, yea, yo, yellow, . . .)
o Any other response (like No/no/N/n/nope/naw/whatever/who cares/red/green/…) will be assumed to be a NO.

Program Control Structures

Use if-else, if-elif … to determine the amount of gas needed for each car type entered by the user.

Deliverables

The deliverable for this project is the following file:
proj02_LastName.py
Be sure to use the specified file name and to submit it for grading via Codio before the project deadline.

OUTPUT to the CONSOLE (Output Sample#1)

(use EXACT format – and NO HARDCODING of the data itself)
Enter Vehicle Name: Ford
Enter Vehicle Type: T
Enter Tank Capacity: 20
Enter Gauge Reading: 50
Get Gas: Put at least 3.33 gallon(s) of gas in your Ford truck
Do you want to enter another car? yes
Enter Vehicle Name: Toyota
Enter Vehicle Type: x
Invalid Vehicle Type.
Please enter (C, S, T) or (c, s, t): s
Enter Tank Capacity: -18
Invalid: Tank Capacity must be a positive number
Enter Tank Capacity: 18
Enter Gauge Reading: 60
Safe to proceed!

 

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
Function Arguments
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.
Similar questions
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