Coding Global Background
Coding Global

Pyhton Script Help

Archived 2 years ago
3 messages
0 members
Created 2 years ago
Updated 2 years ago
Open in Discord
C
earth wanderer
May someone plese run this to see if inputs and outputs work on their end?
# Function to calculate the cost of room
def roomCost(nights, room_type):
    room_prices = {
        "Two Queen Beds": 375,
        "One King Bed": 350,
        "Queen Suite": 525,
        "King Suite": 475,
    }
    if room_type in room_prices:
        return room_prices[room_type] * nights
    else:
        return 0  # Invalid room type

# Function to calculate meal cost
def mealCost(brunches, dinners):
    meal_price = (brunches * 25 + dinners * 75) * 1.15  # Including 15% gratuity
    return meal_price

# Function to calculate excursion cost
def excursionCost(picnic, snorkeling, guided_hike, boat_dinner):
    excursion_price = (picnic * 50 + snorkeling * 25 + guided_hike * 17 + boat_dinner * 200)
    return excursion_price

# Inputs from the user
nights = int(input("Please enter the number of nights: "))
room_type = input("Please enter room selection: ")
brunches = int(input("Please enter the number of brunches: "))
dinners = int(input("Please enter the number of dinners: "))
picnic = int(input("Please enter the number of picnics: "))
snorkeling = int(input("Please enter the number of snorkeling excursions: "))
guided_hike = int(input("Please enter the number of guided hikes: "))
boat_dinner = int(input("Pleae enter the number of boat dinners: "))

# Calculate the total costs
room_total = roomCost(nights, room_type)
meal_total = mealCost(brunches, dinners)
excursion_total = excursionCost(picnic, snorkeling, guided_hike, boat_dinner)
total_cost = room_total + meal_total + excursion_total

# Display the total costs
print("\nCost Breakdown:")
print(f"number of nights: {nights}")
print(f"room cost: ${room_total}")
print(f"meal cost (including gratuity): ${meal_total:.2f}")
print(f"excursion cost: ${excursion_total}")
print(f"total cost: ${total_cost:.2f}")

Replies (3)