Question
Create C++ Code for a program for Hansel's Housecleaning Service. The program prompts the user for a customer's last name only. While the last name
Create C++ Code for a program for Hansel's Housecleaning Service.
The program prompts the user for a customer's last name only. While the last name is not zzz your program will ask for the number of bathrooms and the number of other rooms to be cleaned and display the cleaning charge. You should use a sentinel-controlled while loop in your main loop logic. A customer name of zzz signals the end of the data.
The cleaning charge is $40 plus $15 for each bathroom and $10 for each of the other rooms. Use data validation loop to make sure the number of bathrooms is >= 0, and the number of other rooms is also >= 0. The program will display the total cleaning charge and then prompt for the next customer's name.
When the loop is exited (user enters zzz for the last name), display a message indicating that the program is complete.
Your program will have the main module and a function that, given the number of bathrooms and the number of other rooms, will return that total cleaning charge for the customer.
This is the pseudocode I have
Begin module main
// Declare variables
Declare String name
Declare Real totalBill
Declare Integer NumBathrooms, numRooms
// Read the first name
Display Enter last name or zzz when done:
Input name
// Continue to process while the name is not ZZZZ
While name != ZZZZ
// Read the number of bathrooms
Display Enter number of bathrooms
Input numBathrooms
// Check for invalid input
While numBathrooms < 0
Display Invalid input number of bathrooms cannot be negative
// Read the number of bathrooms again
Display Re-enter number of bathrooms
Input numBathrooms
// Read the number of other rooms
Display Enter number of other rooms
Input numRooms
// Check for invalid input
While numRooms < 0
Display Invalid input number of other rooms cannot be negative
// Read the number of other rooms again
Display Re-enter number of other rooms
Input numRooms
// Call function to calculate the total cleaning bill
totalBill = calcBill(numBathrooms, numRooms)
// Display the bill
Display Your cleaning bill is , totalBill
// Read the next name
Display Enter last name or zzz when done:
Input name
// End While
// Display parting message
Display Program will now end
End module main
Begin function calcBill(Integer bathrooms, rooms)
// Declare variables
Declare Real bill = 40.0 // Initialize to the base amount
// Set up constant for base rate and additional charges
Constant Real BATHROOM_RATE = 15.00
Constant Real ROOM_RATE = 10.00
// Calculate bill
bill = bill + (bathrooms * BATHROOM_RATE) + (rooms * ROOM_RATE)
Return bill
End function calcBill
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started