Question: what code can I add to create a loop that allows the customers to select multiple services? and also adds the total for everything selected

what code can I add to create a loop that allows the customers to select multiple services? and also adds the total for everything selected at the end
My code:
# Function to calculate the total cost based on user choice
def calculate_total():
# Initialize service costs in a dictionary for maintainability
services ={
'B': {'name': 'Boarding', 'cost': 35},
'W': {'name': 'Walking', 'cost': 20},
'D': {'name': 'Daycare', 'cost': 20},
'H': {'name': 'Homecheck', 'cost': 35}
}
# Get customer and pet details
customer_name = input("Please enter your first and last name: ").strip()
pets_name = input("Enter the name of the pet (and type): ").strip()
# Welcome message
print(f"
Hello {customer_name} and {pets_name}!")
print("Welcome To Lisha's Paw-sitive Vibes Extended Stay
")
# Display available services and costs
print("Our services and prices:")
for key, value in services.items():
print(f"{key}: {value['name']}- ${value['cost']}")
# Get user choice of service
service_choice = input(
"
Choose a service (Boarding (B), Walking (W), Daycare (D), Homecheck (H)): "
).upper()
# Initialize total cost
total =0
# Validate service choice and calculate cost
if service_choice in services:
quantity = int(input(f"Enter the number of {services[service_choice]['name'].lower()} sessions/days/nights: "))
total = services[service_choice]['cost']* quantity
else:
print("Invalid service choice!")
exit()
# Apply military discount if applicable
military_discount = input("Are you prior or current military (yes/no): ").strip().lower()
if military_discount == "yes":
discount_rate =5 # 5% discount
discount_amount =(total * discount_rate)/100
total -= discount_amount
print(f"Thank you for your service! You received a 5% military discount of ${discount_amount:.2f}.")
elif military_discount =="no":
print("No military discount applied.")
else:
print("Invalid input. Please enter 'yes' or 'no'.")
exit()
# Display the total cost
print(f"
Your total after discounts is: ${total:.2f}")
return total
# Function to schedule and repeat dates
def schedule_dates():
import datetime
print("
Scheduling your service...")
# Get the starting date for the service
start_date_input = input("Enter the start date for your service (YYYY-MM-DD): ").strip()
try:
start_date = datetime.datetime.strptime(start_date_input, "%Y-%m-%d").date()
except ValueError:
print("Invalid date format! Please use YYYY-MM-DD.")
return
# Get the number of days the service repeats
repeat_days = int(input("Enter the number of days the service will repeat: "))
# Print out all scheduled dates
print("
Here are your scheduled dates:")
for i in range(repeat_days):
scheduled_date = start_date + datetime.timedelta(days=i)
print(f"Day {i +1}: {scheduled_date}")
# Main function to run the program
def main():
calculate_total() # Calculate service cost and handle discounts
schedule_dates() # Schedule dates for the service
# Run the program
if __name__=="__main__":
main()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!