Need Assistance With A Coding Problem

Joined
Aug 26, 2023
Messages
1
Reaction score
0
I am currently learning python and was having some trouble with this problem. See below:

A car rental company charges its customers based on the number of days a car is rented and whether it's a weekday or weekend. The regular weekday rate is $135 per day. However, on weekends, the rate is 1.5 times the regular rate. Additionally, the company offers a special deal: if a customer rents the car for 7 or more days in a row, they get a $50 discount on the total price. Outputs should display currency format with $ signs, two decimals, and commas for thousands.

Example Output:
Enter the number of weekdays the car was rented: 6
Enter the number of weekend days the car was rented 2
Your regular cost is: $810.00
Your weekend cost is: $405.00
Your discount is: $50.00
Your total cost is: $1,165.00

Here is the code I have come up with so far but I am not able to get the if statement section down for the discount part. I'm not really sure about how to go about it.


# Get number of weekdays
weekdays = int(input("Enter the number of weekdays the car was rented: "))

# Get number of weekend days
weekend_days = int(input("Enter the number of weekend days the car was rented "))

# Calculate Reg cost
regular_cost = 135 * weekdays
print(f"Your regular cost is: ${regular_cost:.2f}")

# Calculate weekend days cost
weekend_cost = 135 * 1.5 * weekend_days
print(f"Your weekend cost is: ${regular_cost:.2f}")

total_cost = regular_cost + weekend_cost

if weekdays + weekend_days >= 7:
print(f'Your total cost is: ${total_cost:.2f} - 50')
else:
print(f"Your total cost is: ${total_cost:.2f}")
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,968
Messages
2,570,153
Members
46,701
Latest member
XavierQ83

Latest Threads

Top