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

1 Expert Approved Answer
Step: 1 Unlock

Heres how you can write a C program based on the provided pseudocode for Hansels Housecleaning Service cpp include include Function to calculate the c... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!