Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I can't figure out why my code does not work # Week 4 Assignment # This program is to calculate the cost of house cleaning

I can't figure out why my code does not work
# Week 4 Assignment
# This program is to calculate the cost of house cleaning
# Define Functions -----------------------------------------------------------------------------------------
# Welcome ------------------------------
def Welcome():
# This function displays the Welcome message
print("
Welcome!")
print("
This program will calculate the cost of your house cleaning.")
print("
The services we provide:
")
#Display options for cleaning types
print("1. Basic: Includes regular cleaning of windows, doors, baseboards, dusting, and all furniture wiped.")
print("2. Premium: Includes deep cleaning of inside cabinets, oven cleaning, and moving furniture.")
print("3. Deluxe: Includes Premium cleaning plus laundering of bedding, curtains, bath, and kitchen rugs.
")
# GetNumRooms ------------------------
def GetNumRooms():
#Prompt the user for number of rooms
numRooms = int(input("How many rooms do you have?\t"))
#Validate input
if (numRooms <=5): #A small house is 5 rooms or less
# Display result for a small house
print("
This number of rooms is the Small package
")
elif (numRooms >=6 and numRooms <=8): #A medium house is 6-8 rooms
#Display result for a medium house
print("
This number of rooms is the Medium package
")
elif (numRooms >=9): #A large house is 9 or more rooms
#Display result for a large house
print("
This number of rooms is the Large package
")
#Set price for house size
if (numRooms <=5):
numRoomsCost =150 #A small house is $150
elif (numRooms >=6 and numRooms <=8):
numRoomsCost =200 #A medium house is $200
elif (numRooms >=9):
numRoomsCost =250 #A large house is $250
return(numRooms)
# GetCleanType ------------------------
def GetCleanTypeCost ():
#Prompt the user for cleaning type
cleanType = int(input("What cleaning type would you like to select?
Enter 1 for basic, 2 for premium, or 3 for deluxe\t"))
#Validate input
if (cleanType ==1):
# Display result for basic cleaning
print("
There is no additional fee for a Basic cleaning")
elif (cleanType ==2):
#Display result for a premium cleaning
print("
There is a $50 charge for a Premium cleaning")
elif (cleanType ==3):
#Display result for a deluxe cleaning
print("
There is a $100 charge for a Deluxe cleaning")
#Set price for cleaning type
if (cleanType ==1):
cleanTypeCost =0 #A basic cleaning is extra charge, $0
elif (cleanType ==2):
cleanTypeCost =50 #A premium cleaning is $50 more
elif (cleanType ==3):
cleanTypeCost =100 #A deluxe cleaning is $100 more
return(cleanType)
# CalCustCost ------------------------
def CalCustCost (numRoomsCost,cleanTypeCost):
# This function calculates all costs per customer
# Input: numRooms, cleanType
# Output: numRooms, cleanType, totalCost - total customer cost
#Calcuate the total cost
totalCost = numRoomsCost + cleanTypeCost
return(numRoomsCost,cleanTypeCost,totalCost)
# DisplayOutput ------------------------
def DisplayCustOutput (numRoomsCCost, cleanTypeCCost,totalCCost):
# This function displays the number of rooms, cleaning type, and the total cost
# Input: numRoomsCCost - number of rooms cost
# cleanTypeCCost - type of cleaning type cost
# totalCCost - total for house cleaning
# Output: none
#Display the output
print("
")
print("The total for the number of rooms: $", numRoomsCCost)
print("The total for the cleaning type: $", cleanTypeCCost)
print("The total for the house cleaning: $", totalCCost)
# Main ---------------------------------------------------------------
def main():
# Display Welcome message
Welcome()
#Prompt user for number of rooms
numRooms = GetNumRooms()
#Prompt user for clean type
cleanType = GetCleanTypeCost()
#Calculate the customer cost
totalCost =(cleanType + numRooms)
#Diplay output
DisplayCustOutput (numRooms, cleanType, totalCost)
#--- Execute -----------------------------------------------
main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

1. Identify and control your anxieties

Answered: 1 week ago