Service Price

Basic Lawn Mowing $20
Trimming and Sweeping $25
Pool Cleaning $50
Watering Plants $10

Prompt the user to input whether or not they want each of the services. You can assume the input will be a character that is either a 'y' or an 'n'. Print out the total of the bill. Write this as efficiently as you can, using as few comparisons and if statements as possible, no more than 4 if statements.

Example run:
Enter your choices as y or n.
Do you want Basic Lawn Mowing? y
Do you want Trimming and Sweeping? n
Do you want Pool Cleaning? y
Do you want Watering Plants? n

The total for your services is $70
Thank you for your business!

I'm having a little trouble with this problem. Anyone got any ideas

To solve this problem efficiently with a maximum of 4 if statements, you can use the following approach:

1. Define the prices for each service as variables:
- basic_lawn_mowing_price = 20
- trimming_and_sweeping_price = 25
- pool_cleaning_price = 50
- watering_plants_price = 10

2. Prompt the user to input whether they want each service using the 'y' or 'n' options.
3. Read the user's input and store it in variables for each service:
- basic_lawn_mowing_choice
- trimming_and_sweeping_choice
- pool_cleaning_choice
- watering_plants_choice

4. Calculate the total price using the following formula:

total_price = (basic_lawn_mowing_price * basic_lawn_mowing_choice) +
(trimming_and_sweeping_price * trimming_and_sweeping_choice) +
(pool_cleaning_price * pool_cleaning_choice) +
(watering_plants_price * watering_plants_choice)

5. Print the total price to the user and thank them for their business.

Here's a possible implementation in Python:

```python
# Define the prices for each service
basic_lawn_mowing_price = 20
trimming_and_sweeping_price = 25
pool_cleaning_price = 50
watering_plants_price = 10

# Prompt the user for their choices
basic_lawn_mowing_choice = input("Do you want Basic Lawn Mowing? (y/n): ")
trimming_and_sweeping_choice = input("Do you want Trimming and Sweeping? (y/n): ")
pool_cleaning_choice = input("Do you want Pool Cleaning? (y/n): ")
watering_plants_choice = input("Do you want Watering Plants? (y/n): ")

# Calculate the total price
total_price = (basic_lawn_mowing_price * (basic_lawn_mowing_choice == 'y')) + \
(trimming_and_sweeping_price * (trimming_and_sweeping_choice == 'y')) + \
(pool_cleaning_price * (pool_cleaning_choice == 'y')) + \
(watering_plants_price * (watering_plants_choice == 'y'))

# Print the total price to the user
print(f"The total for your services is ${total_price}")
print("Thank you for your business!")
```

This implementation uses the fact that in Python, the expression `(choice == 'y')` will evaluate to `True` if `choice` is equal to `'y'`, and `False` otherwise. By multiplying each price with this boolean value, we effectively include or exclude the service cost based on the user's choice.