Question: Chapter 11 and 12 Homework Class Structures Problem You work for a flooring and painting company called ACME as a project manager. ACME supplies residential

Chapter 11 and 12 Homework Class Structures Problem You work for a flooring and painting company called ACME as a project manager. ACME supplies residential and commercial carpet and painting services. Your office is in charge of visiting sites and preparing the estimates for customers. Up until now, everything is done by hand and often there are mistakes in calculating the square footage for floors and walls. ACME is losing money on many jobs. After taking EGR 126, you decide that you can create an object?oriented program using a Class to keep track of the information when visiting sites for estimates.

The program needs to do the following.

1. Define a base Class called Floor. Floor is used to keep track of the area of each room at the site.

2. Floor should contain three members. a. A room ID using an integer. b. The length of the room using a double. c. The width of the room using a double.

3. The Base class should the follow methods. a. A base constructor. Defaults = 0.0 b. An accessor. c. An inline method called getID() which returns just the ID. d. Overloads of the equal to operator ==. e. And an method called area() which calculates the area of the room in ft2.

4. There should be two friend functions. a. yards , passes an object of Floor. Returns a double, the yards of a 12 foot roll needed for each room. b. change, passes an object of Floor and an integer ID. Changes the object with the matching ID.

5. In this exercise, there are exactly 5 rooms. Yes, this is unrealistic, but to simplify, we are assuming 5 rooms. You should create and populate an array of Floors as shown below. Remember, each element of an array is now an object of the Class. How cool!

6. Assign your objects with the following info. Yes, this is hand coded. When you get a real job, you can create a GUI to enter the data on the job!

7. The base class should first display all of the rooms using the accessor. Be creative, but the info needed is similar to the figure below. Yep, looks like a for loop would work nicely. Only of course if you are using an array. ?

8. Next your program should prompt to change a room ID. Thats where the mutator comes in. Oh, yeah, the mutator in this case is a friend function called change. An object is passed to it along with an ID. If the ID passed matches the objects member ID then prompt for and change the width and length. Put this in do?while.

9. Next, create some code that allows the user to look at any ID. This is where the overload of == comes in. In this case, we are just looking for equivalence of two objects IDs. If there is match then use your accessor to show that you found a match. Here is an idea for generating the object to compare your array against. Just an idea.

10. Next, use the area() method to calculate the square area for each of the 5 rooms. Piece of cake. Actually, its a piece of carpet.

11. Next, create a friend function, yards, for calculating the number of yards of a 12 foot wide roll of carpet needed for each room. Suppose the room is 12 feet long by 10 feet wide. You would need 4 yards of a roll. There would be 2 feet of wasted carpet. Now suppose the room was 13 ft L x 10 feet W. You would need 5 yards. You have to round up to the next yardage. To round to the next yard, use the ceil function. Now, if the room is wider than 12 feet, you need to determine how many rolls are needed for the width. Round up to the next roll. For example, if the room is 13 ft L x 13 feet W you need 10 yards of a roll. 5 yards for the first 12 ft. 5 yards for the next 1 ft. Yes, ACME is rather wasteful. Oh, well, thats something for you to figure out when you get a real job. How to optimize the use of the carpet. See examples below for each room, how many yards of the 12 ft wide roll are needed. Use your method getID() to display the ID in the cout statement.

REV A Hey ACME programmers. If you havent coded this yet and if you want to just convert from square ft to square yds, that may be a better approach. Our installers told us that we are allowed to have seams so we can cut up the carpet as needed. If that is the case, just do unit conversion to square yards but round up to the next integer. You can use the ceil function for that. The results for the rooms above would be as follows.

12. Now that the individual yards of a 12 ft roll have been determined for each room ID, the total number of yards must be calculated and then a price. Use $30 per yard to calculate the final cost to the customer. Rev A If you decided to report the exact number of square yards, multiply the total of all yards by $6.0 per sq yards as shown below.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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!