Question

In: Computer Science

need to write code for a Paint job estimator program on python specs: A painting company...

need to write code for a Paint job estimator program on python

specs:

A painting company has determined that for every 350 square feet of wall space, one gallon of paint and six hours of labor are required. The company charges $62.25 per hour for labor. Write a program call paintjobestimator.py that asks the user to enter the square feet of wall space to be painted and the price of the paint per gallon. The program is to display the following information.

  • The number of gallons of paint required rounded up to whole gallons.
  • The hours of labor required.
  • The cost of the paint based on the rounded up whole gallons.
  • The labor charges.
  • The total cost of the paint job.

At the end of one estimate the user it to be asked if they would like to perform another estimate. Use the prompt: Would you like to do another estimate? (y/n) If the user answers y, then the program is to accept input for another estimate. If the user answers with anything other than y, the program is to exit.

The user input should not be able to crash the program. If the user provides invalid input the program should tell the user why the input is invalid and ask again for the input.  

The square feet of wall space and the price of the paint per gallon must be positive values. If the user enters 0 or a negative value, the program should tell the user why the input is invalid and ask again for the input.

The output is to be nicely formatted. Hours of labor is to be displayed to one decimal point (example: 12.4 hours). Gallons of paint is to be displayed as an integer value with nothing shown to the right of the decimal point (example: 5). Total labor charges is to be displayed to two decimal points and a $ is to be displayed at the start of the total labor charge value (example: $152.64).

The gallons of paint is rounded up to whole gallons because the paint is colored and mixed in whole gallons. If paint is left over it can’t be used on another job. You will need to find a way in Python to do the math to calculate the gallons of paint so that the result is a whole number that is a rounded up value based on the division of the square feet of space by the 350 square feet per gallon. For example, if the area to be painted is 1800 square feet, then 1800 / 350 is 5.142857 gallons. The rounded up whole gallons result is 6. Five gallons of paint is not enough. The need for some amount more than 5 gallons means the job requires 6 gallons even if all of it will not be used.

this is what i have so far:

import math


def main():
while True:

# Taking the input from the user for the square feet of the wall to paint and ask use until the user enters positive integer value

while True:

square_feet = input('Enter square feet of wall to paint: ')

square_feet = int(square_feet)

if square_feet < 0:

print('square feet has to be positive integer')

continue

elif square_feet == 0:

print('square feet must be positive not zero')

continue

# if square feet is greater than 0 the loop terminates

else:

break

# Taking the input from the user for the pricePaint of the painting bucket and ask the user until the user enters positive integer value

while True:

pricePaint = input('Enter pricePaint of paint per gallon: ')

pricePaint = int(pricePaint)

if pricePaint < 0:

print('price has to be positive integer')

continue

elif pricePaint == 0:

print('price has to be positive integer not zero')

continue

# if pricePaint > 0 the loop terminates

else:

break

# getting Gallons based on the price of the paint

Gallons = square_feet / 350

# calculating the number of numOfHours required to paint

number_of_hours = Gallons * 6

Gallons = math.ceil(Gallons)

# getting cost of the paint from Gallons

paintCost = pricePaint * Gallons

# getting theLaborCharge based on number of numOfHours

the_Labor_Charge = 62.25 * number_of_hours

# calculating total paint cost

totalCost = paintCost + the_Labor_Charge

print("Gallons: %5d, number of hours of labor: %.1f, Paint Cost: %.2f, the Labor Charge: $%.2f, Total Paint Cost: $%.2f" % (
Gallons, number_of_hours, paintCost, the_Labor_Charge, totalCost))

# getting choice from user

choice = input('Would you like to do another estimate(y/n)? ')

# if the choice is yes the program will do another estimate

if choice.upper() == 'Y':

pass

# if the choice is no or anything then program will terminate

elif choice.upper() == 'N' or choice.upper() != 'N':

break


if __name__ == "__main__":
main()

----

when the user puts in a negative number or 0 for the square ft of wall space and price of paint it advises them to use another value but when they use a decimal number such as "9.99" it crashes.

I need to make to where it takes all kinds of inputs including decimal numbers and advise them to try another value if they put in 0 or a negative number. if someone could also help me tidy up how it spits the end result it would be great

Solutions

Expert Solution

import math

def main():
   while True:

      # Taking the input from the user for the square feet of the wall to paint and ask use until the user enters positive integer value
      while True:
         square_feet = input('Enter square feet of wall to paint: ')
         square_feet = float(square_feet)

         if square_feet < 0:
            print('square feet has to be positive integer')
            continue

         elif square_feet == 0:
            print('square feet must be positive not zero')
            continue

         # if square feet is greater than 0 the loop terminates
         else:
            break

      # Taking the input from the user for the pricePaint of the painting bucket and ask the user until the user enters positive integer value
      while True:
         pricePaint = input('Enter pricePaint of paint per gallon: ')
         pricePaint = float(pricePaint)

         if pricePaint < 0:
            print('price has to be positive integer')
            continue

         elif pricePaint == 0:
            print('price has to be positive integer not zero')
            continue

         # if pricePaint > 0 the loop terminates
         else:
            break

      # getting Gallons based on the price of the paint
      Gallons = square_feet / 350

      # calculating the number of numOfHours required to paint
      number_of_hours = Gallons * 6
      Gallons = math.ceil(Gallons)

      # getting cost of the paint from Gallons
      paintCost = pricePaint * Gallons

      # getting theLaborCharge based on number of numOfHours
      the_Labor_Charge = 62.25 * number_of_hours

      # calculating total paint cost
      totalCost = paintCost + the_Labor_Charge

      print("\nGallons: %d, \nNumber of hours of labor: %.1f, \nPaint Cost: %.2f, \nThe Labor Charge: $%.2f, \nTotal Paint Cost: $%.2f\n" % (
      Gallons, number_of_hours, paintCost, the_Labor_Charge, totalCost))

      # getting choice from user
      choice = input('Would you like to do another estimate(y/n)? ')

      # if the choice is yes the program will do another estimate
      if choice.upper() == 'Y':
         pass

      # if the choice is no or anything then program will terminate
      elif choice.upper() == 'N' or choice.upper() != 'N':
         break


if __name__ == "__main__": main()

FOR HELP PLEASE COMMENT.
THANK YOU.


Related Solutions

Please write in beginner level PYTHON code! Your job is to write a Python program that...
Please write in beginner level PYTHON code! Your job is to write a Python program that asks the user to make one of two choices: destruct or construct. - If the user chooses to destruct, prompt them for an alternade, and then output the 2 words from that alternade. - If the user chooses construct, prompt them for 2 words, and then output the alternade that would have produced those words. - You must enforce that the users enter real...
Write a program in PYTHON that determines the cost of painting the walls of a windowless...
Write a program in PYTHON that determines the cost of painting the walls of a windowless room. There is one door and it will be painted the same color as the walls. The problem requires a main function and two custom functions that are imported from a custom module that you create. In main, the program should prompt the user for five inputs shown in blue in the Sample Output below: the length, width, and height of the room in feet. the...
I need to write this program in Python. Write a program that displays a temperature conversion...
I need to write this program in Python. Write a program that displays a temperature conversion table for degrees Celsius and degrees Fahrenheit. The tabular format of the result should include rows for all temperatures between 70 and 270 degrees Celsius that are multiples of 10 degrees Celsius (check the sample below). Include appropriate headings on your columns. The formula for converting between degrees Celsius and degrees Fahrenheit is as follow F=(9/5C) +32 Celsius Fahrenheit 70 158 80 176 90...
please answer this in a simple python code 1. Write a Python program to construct the...
please answer this in a simple python code 1. Write a Python program to construct the following pattern (with alphabets in the reverse order). It will print the following if input is 5 that is, print z one time, y two times … v five times. The maximum value of n is 26. z yy xxx wwww vvvvvv
6.27 Ch 2 Program: Painting a wall (C++) (4)Calculate the cost of the paint. Paint comes...
6.27 Ch 2 Program: Painting a wall (C++) (4)Calculate the cost of the paint. Paint comes in six colors (Red, Yellow, Green, Blue, Black,White) Assign numbers 0-5 to these paint colors ie Red =0 and White =5. The costs for each of these paints is as follows:(2 pts) Now your program will be submission ready. Main.cpp #include <iostream> #include <cmath> using namespace std; #include "paint.h" int main() {    double wallHeight;    double wallWidth;    double wallArea;    double gallonsPaintNeeded;...
I need to write a program in python for a restaurant. The program should let the...
I need to write a program in python for a restaurant. The program should let the user enter a meal number, then it should display the meal name, meal price, and meal calories. Also, needs the appropriate output if the user enters an invalid meal number. I am supposed to use a dictionary, but my problem is it keeps giving me an error and telling me my menu is not defined. Not sure what I am doing wrong. print ("Welcome...
Please write in Python code Write a program that stores the following data in a tuple:...
Please write in Python code Write a program that stores the following data in a tuple: 54,76,32,14,29,12,64,97,50,86,43,12 The program needs to display a menu to the user, with the following 4 options: 1 – Display minimum 2 – Display maximum 3 – Display total 4 – Display average 5 – Quit Make your program loop back to this menu until the user chooses option 5. Write code for all 4 other menu choices
ASAP! write a program including   binary-search and merge-sort in Python. You also need to  modify the code posted...
ASAP! write a program including   binary-search and merge-sort in Python. You also need to  modify the code posted and use your variable names and testArrays.  
CODE IN PYTHON 1. Write a program that asks the user for the number of slices...
CODE IN PYTHON 1. Write a program that asks the user for the number of slices of pizza they want to order and displays the total number of dollar bills they owe given pizza costs 3 dollars a slice.  Note: You may print the value an integer value. 2. Assume that y, a and b have already been defined, display the value of x: x =   ya+b    3. The variable start_tees refers to the number of UD T-shirts at the start...
Write a program function code in Python that prompts the user to enter the total of...
Write a program function code in Python that prompts the user to enter the total of his/her purchase and add 5% as the VAT. The program should display the total without and with VAT. ( that mean i should ask the user to enter the number of their item " so i think that i should use range" then print the result with and without the VAT )
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT