Skip to main content

Section 2.14 Unit 2 Selection Project

45 minutes
The Smart Parking Fee Calculator project was designed by Leigh Anne Fitz of Virginia Beach City Public Schools and the autograding tests were designed by Kate McDonnell of Cherry Creek Schools in Colorado.

Subsection 2.14.1 Smart Parking Fee Calculator

A downtown parking garage wants to replace its manual parking-fee system with a Python program. The program will ask a customer for information about their parking visit and determine how much they owe. The garage has different rates depending on how long the customer parked and whether they are a garage member. The program should also determine whether the customer qualifies for free parking.
Create a Python program that determines a customer’s parking fee based on information they provide. Your program should make decisions using Boolean expressions and display a personalized receipt. Be sure to format all dollar amounts in the receipt to two decimal places.
Program Requirements: Ask the user for the following information and store the input into variables.
  • Customer name
  • Number of hours parked
  • Whether they are a garage member (yes or no)
  • Whether they parked on a weekend (yes or no)
Table 2.14.1. Parking Rates
Parking Time Regular Customer Member
0.5 to 2 hours $5 $3
More than 2 hours to 4 hours $10 $7
More than 4 hours to 8 hours $18 $12
More than 8 hours $25 $18
Special Rules:
  • Members receive a discounted rate (see table above).
  • Parking for 30 minutes or less is free.
  • On weekends, all customers receive an additional 20% discount.
  • A customer who parks for more than 12 hours receives a warning that they have exceeded the recommended parking time.
Table 2.14.2. Sample Outputs
Regular Weekend Free Parking Long-Term Parking
Inputs:
Customer name: Morgan
Hours parked: 3
Are you a member? no
Is today a weekend? no
Inputs:
Customer name: Jordan
Hours parked: 5
Are you a member? yes
Is today a weekend? yes
Inputs:
Customer name: Alex
Hours parked: 0.5
Are you a member? no
Is today a weekend? no
Inputs:
Customer name: Taylor
Hours parked: 14
Are you a member? no
Is today a weekend? no
------------------------------
           RECEIPT
------------------------------
Customer: Morgan
Parking Time: 3.0 hours
Customer Type: Regular

Parking Fee: $10.00
Weekend Discount: $0.00

------------------------------
Amount Due: $10.00
------------------------------

Thank you for parking with us!
------------------------------
            RECEIPT
------------------------------
Customer: Jordan
Parking Time: 5.0 hours
Customer Type: Member

Parking Fee: $12.00
Weekend Discount: $2.40

------------------------------
Amount Due: $9.60
------------------------------

Thank you for parking with us!
------------------------------
            RECEIPT
------------------------------
Customer: Alex
Parking Time: 0.5 hours
Customer Type: Regular

Parking Fee: $0.00

Amount Due: $0.00

Your parking visit is free!
------------------------------
            RECEIPT
------------------------------
Customer: Taylor
Parking Time: 14.0 hours
Customer Type: Regular

Parking Fee: $25.00

Amount Due: $25.00

WARNING: You have exceeded the 
recommended 12-hour parking time.

Project 2.14.1 Smart Parking Fee Calculator.

Create a Python program that determines a customer’s parking fee based on information they provide. Your program should make decisions using Boolean expressions and display a personalized receipt. Be sure to format all dollar amounts in the receipt to two decimal places in print using round(num, 2) or format(num, ".2f").

Subsection 2.14.2 Project Reflection

Activity 2.14.2 Project Reflection: Selection.

Describe a selection statement that you used in your app. What was the condition and what happened when the condition was true or false? How did you test both branches of the selection statement to make sure it was working correctly?

Activity 2.14.3 Project Reflection: Errors.

Describe an error that you encountered while you were creating the code, and how you fixed your code to remove the bug. How did you test the code to make sure it was working correctly?
You have attempted of activities on this page.