142k views
3 votes
Write a program for The Carefree Resort named ResortPrices that prompts the user to enter the number of days for a resort stay. Then display the price per night and the total price. Nightly rates are: $200 for one or two nights $180 for three or four nights $160 for five, six, or seven nights $145 for eight nights or more For example, if the input is 1, the output should be: Price per night is $200.00 Total for 1 night(s) is $200.00

User Estefani
by
7.5k points

1 Answer

5 votes

Final answer:

The student's question involved writing a program that calculates the total price and price per night for a stay at a resort, with different rates depending on the length of stay. The provided Python program example takes the number of days as input, determines the nightly rate using conditional statements, and then calculates and outputs the total cost and price per night.

Step-by-step explanation:

The student has asked for a program that calculates the total price for a stay at The Carefree Resort based on the number of days and the respective nightly rates. A simple way to write this program is by using conditional statements to determine the rate based on the number of nights stayed.



Here is an example of how such a program could be structured in Python:



num_days = int(input('Enter the number of days for your resort stay: '))
if num_days <= 2:
rate = 200
elif num_days <= 4:
rate = 180
elif num_days <= 7:
rate = 160
else:
rate = 145

price_per_night = '${:.2f}'.format(rate)
total_price = '${:.2f}'.format(rate * num_days)

print(f'Price per night is {price_per_night}')
print(f'Total for {num_days} night(s) is {total_price}')



When the user enters the number of days, the program will determine the correct nightly rate and then calculate and display the total price for the entire stay.

User Adrian Seeley
by
7.4k points