Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a program in C++ wherein users will provide the number of rooms in their apartment along with the dimensions of each room in terms

Write a program in C++ wherein users will provide the number of rooms in their apartment along with the dimensions of each room in terms of its length and width (in feet and inches). Using these inputs your program should tell the user what will be the total cost to carpet the entire apartment.
Note: 1 feet = 12 inches
Cost of carpeting = $2.51/ft^2
Make sure your program consists of the following functions:
1. inputRooms(): will ask the user for an integer input and return the value back to main function.
2. validateRooms(): will take as input the value returned by inputRooms(); check for its validity and return a true or false value back to main function based on the user input being correct or incorrect. If incorrect, inputRooms() will be called again.
3. roomDimensions(): Will ask the user for the integer dimensions of the rooms in terms of feet and inches and return back the values to the main function. If you want, you can write separate inputDimensions() for length and width of the room.
4. validateDimensions(): same as validateRooms(); but with the input returned by roomDimensions().
5. convertInches(): Take as input the integer inches of the room dimension and return back the converted float value. Note, if you are converting feet to inches then you will have a convertFeets() function instead of convertInches().
6. computeArea(): Takes input the converted float Dimension values of a room and computes the float area and returns it back to main function.
7. computeCost(): Takes input the float area and constant float pricing per sq. feet and computes the total cost of carpeting and returns the float total cost.
8. printResults(): Takes input the float total cost and prints the results. Returns nothing back to main function.
You are free to use any other functions that you deem appropriate, either using call by value or call by reference. Do note the description of the functions above is given based on call by value. In case you use call by reference the function prototypes will change according to how you use call by reference.
Note: You will still have the For loops and while loops you used in Lab 5. But their bodies will consist of the function calls to the above functions.
Please make sure your program has all the function declarations before starting the main function (as shown in lab previously). Write the function definition after the end of the main function. (Worth 5 points.)
Other Grading Policies specific to this lab:
Having each of the 8 functions specified above is worth 2.5 points (net 20 points)
Correct total cost - 5 points
Make sure for room dimensions; the user is not able to input a negative value. In case they do, they should be prompted and asked to re-enter the dimensions again with a valid input. Also, the input for number of rooms should be at least 1. Your program must use for loops in computing the total carpeting cost.
The entire program should be able to run as many times as a user wants.
Make sure your code is well documented and output is well structured.
Input Cases:
Rooms = -7 (Correct: 2)
Room 1:
Length: 7 ft and -7 (correct: 2) inches
Width: -9 (correct: 9) ft and 9 inches
Room 2:
Length: 11 ft and 4 inches
Width: 10 ft and 10 inches

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

Lab Manual For Database Development

Authors: Rachelle Reese

1st Custom Edition

1256741736, 978-1256741732

More Books

Students also viewed these Databases questions

Question

=+ d. a professor deciding how much to prepare for class

Answered: 1 week ago