Welcome to the CSC Q&A, on our server named in honor of Ada Lovelace. Write great code! Get help and give help!
It is our choices... that show what we truly are, far more than our abilities.

Categories

0 votes
def main():
    # get input from the user
    area = float(input("Enter area to be painted: ")) 
    cost = float(input("Enter cost of one gallon: "))
    cost = float(input("Enter cost of one hour of labor: "))
    # use assignment statements to compute the values
    gallons = area / 115
    hours = gallons * 3.5
    paint = gallons * cost
    labor = hours * cost
    total = paint + labor
    # use print to give the results
    print()
    print(f"Area: {area} square feet")
    print(f"Paint: {gallons} gallons")
    print(f"Labor: {hours} hours")
    print(f"Paint Cost: {paint}")
    print(f"Labor Cost: {labor}")
    print(f"Total Cost: {total}")    
#call function main    
main()
asked in CSC201 Spring 2025 by (101 points)

1 Answer

0 votes

Because you use the same cost variable twice, it will just end up storing the 2nd thing that the user inputs (labor cost), and your program won't know/use the cost per gallon of paint.

Instead, use two different variables: laborCostPerHour and paintCostPerGallon.

Hope that helps!

answered by (280 points)
...