88.2k views
4 votes
Write a program that prompts the user for their quarterly water bill for the last four quarters. The program should find and output their average monthly water bill. If the average bill exceeds $75, the output should include a message indicating that too much water is being used. If the average bill is at least $25 but no more than $75, the output should indicate that a typical amount of water is being used. Finally, if the average bill is less than $25, the output should contain a message praising the user for conserving water. Use the sample run below as a model for your output.

User Calamar
by
6.3k points

1 Answer

4 votes

Answer:

total = 0

for i in range(4):

bill = float(input("Enter bill for quarter " + str(i+1) + ": "))

total += bill

average = total / (4 * 3)

if average > 75:

print("Average monthly bill is $" + str(average) + ". Too much water is being used")

if 25 <= average < 75:

print("Average monthly bill is $" + str(average) + ". A typical amount of water is being used")

if average < 25:

print("Average monthly bill is $" + str(average) + ". Thank you for conserving water")

Step-by-step explanation:

*The code is in Python.

Create a for loop that asks the user to enter the bill for 4 quarters and calculate the total of the bills

Calculate the average monthly bill, divide the total by 12

Check the average for the given conditions. Depending on its value print the required message along with the average monthly bill

User Svalorzen
by
6.1k points