• Log in or sign up for an account here: https://www.sythe.org/login

Stuck on a problem.

kmjt

-.- The nocturnal life chose me -.-

Banned
Joined
Aug 21, 2009
Sythe Gold
449
Messages
14,450
Location
Canada
I'm working on a problem but i'm having trouble doing some of the things required. The problem asks me to make a program that:

-Asks the user to enter the square feet of wall to be painted and the price that paint is.
-Displays the number of gallons of paint required.
-Displays the hours of labour required.
-Displays the cost of the paint.
-Displays the labour charges.
-Displays the total cost of the paint job.

I'm given a bit of information:

For every 115 square feet of wall space, one gallon and eight hours of labour are required from this painting company. The company charges $20.00 per hour of labour.

I can make the function but I am lacking some things.. The problem asks that:

-Make comprehensive use of value-returning functions.
-Have a function of each of the computations required in the question.
-Each function computes a value and then returns it.
-Seperate input and output from these functions by making sure that all input and output are done by the main function.
-Use main function to control the calling of other functions, passing of parameters to the other functions and the storing of values returned from the other functions.
-Don't have global variables.

How can I change my code into that? This is my code:

Code:
# Creating wall_space variable.
wall_space = input("Enter the square feet of wall space to be painted: ")

# Creating paint variable
paint = input ("Enter the price of paint per gallon ($): ")




# Defining the main function.
def main():

 

    # Calling the gallons function.
    gallons()

    # Calling the labor_hours function.
    labor_hours()

    # Calling the paint_price function.
    paint_cost()

    # Calling the labor_price function.
    labor_cost()

    # Calling the total_cost function.
    total_cost()




# Defining the gallons function.
def gallons():
    
    # Creating the gallons variable.
    gallons = wall_space / 115.0

    print "Gallons of paint required:", gallons




# Defining the labor_hours function.
def labor_hours():

    # Creating the labor_hours variable.
    labor_hours = (wall_space / 115.0) * 8.0

    print "Hours of labor required:", labor_hours




# Defining the paint_cost function.
def paint_cost():

    # Creating the paint_price variable.
    paint_price = paint * (wall_space / 115.0)

    print "Cost of paint charges:", paint_price




# Defining the labor_cost function.
def labor_cost():

    # Creating labor_hours variable.
    labor_price = ((wall_space / 115.0) * 8.0) * 20.00

    print "Cost of labor charges ($):", labor_price




# Defining the total_cost function.
def total_cost():

    # Creating the total_cost variable.
    total_cost = (paint * (wall_space / 115.0)) + (((wall_space / 115.0) * 8.0) * 20.00)

    print "Total cost:", total_cost




# Calling the main function.
main()
 
EDIT: -Use main function to control the calling of other functions, passing of parameters to the other functions and the storing of values returned from the other functions.

my code doesn't do that. You need to rewrite all your functions to make that happen im too lazy
 
Runescape Gamblingrunescape gambling
Back
Top