130k views
2 votes
A painting company has determined that for every 112 square feet of wall space, one gallon of paint and eight hours of labor will be required. The company charges $35.00 per hour for labor. The price of paint is $50 per gallon. Write a program that will calculate the price to paint the interior of a house. The file named rooms.txt contains the square footage of each room on separate lines. For each record in the file, calculate the following: • The number of gallons of paint required • The hours of labor required • The cost of the paint • The labor charges • The total cost of the paint job for each room These values should be displayed in an output file. Be sure to include descriptive labels for each value. Once all rooms have been processed, display in the file, the total amount of the paint job. You are required to create and use correctly (with appropriate parameters) the following functions: • A function to calculate the number of gallons of paint required • A function to calculate the hours of labor required • A function to calculate the cost of the paint • A function to calculate the labor charges • A function to calculate the paint job cost for each room • Any other functions you think are necessary You can either write a function or functions to display the output or do this in the main function. Add the following comments to the beginning of the program. Name: Your Name Class and Section: CS 120 01 Assignment: Final Project Program Description: You write a short description of what the program will do Be sure to include the following: • Descriptive variable and constant names • Comments for each function, explaining what the function is doing In order to receive credit for this assignment, do the following: • Create a folder with the following name: Final Project • Copy your program and all data files to this folder • Zip the folder • Submit the zipped file

User Jhaman Das
by
9.0k points

1 Answer

2 votes

Below is a Python program that accomplishes the described task. The comments at the beginning of the program provide an overview of the functions and their purposes.

# Function to calculate the number of gallons of paint required

def calculate_paint_gallons(square_feet):

return square_feet / 112

# Function to calculate the hours of labor required

def calculate_labor_hours(square_feet):

return square_feet / 112 * 8

# Function to calculate the cost of paint

def calculate_paint_cost(gallons_needed, paint_price_per_gallon):

return gallons_needed * paint_price_per_gallon

# Function to calculate labor charges

def calculate_labor_charges(labor_hours, labor_rate):

return labor_hours * labor_rate

# Function to calculate the paint job cost for each room

def calculate_room_cost(square_feet, paint_price_per_gallon, labor_rate):

gallons_needed = calculate_paint_gallons(square_feet)

labor_hours = calculate_labor_hours(square_feet)

paint_cost = calculate_paint_cost(gallons_needed, paint_price_per_gallon)

labor_charges = calculate_labor_charges(labor_hours, labor_rate)

total_cost = paint_cost + labor_charges

return gallons_needed, labor_hours, paint_cost, labor_charges, total_cost

User Ronn Macc
by
8.5k points