Specific directions | Computer Science homework help


RATS! You thought everything was going great in the painting design for Program #2’s small cabin, but as often happens, the user has changed his/her mind! Windows are to be added after all, so now you need less paint and have to buy some windows, instead.

Don't use plagiarized sources. Get Your Custom Essay on
Need an answer from similar question? You have just landed to the most confidential, trustful essay writing service to order the paper from.
Just from $11/Page
Order Now

In Program #2, you calculated the amount of wall & ceiling area to determine how much paint to buy, and you planned to paint the entire surface. Several changes are now needed: a specified number of windows will be planned for; and the ceiling will not be painted—too drab! Since your program will grow, there’s no better time than now to keep the design simple by incorporating functions wherever possible. Your new, improved version will use two functions to keep the logic as logical as possible!

The house specifics: still a simple rectangular structure, but now you’re only concerned with the wall surfaces—the ceiling will be handled elsewhere. You’ll still need to request the length, width, and height of the structure. Do that in main(). But, then, you’ll call two separate functions to calculate most of the details. We want to know what the total wall surface area is, how many windows are allowed/desired, and finally how much paint will be needed.

Use the following functions, by name, in your design for this program.

main: As usual. You may do all input and output in main.

calc_area: Calculate the total surface area of the walls and return the answer to main. (You’ll need

to decide which variable values need to be “sent in” to this function.)

calc_windows: Calculate and return how many windows are recommended for environmental reasons.

Use this rule: a maximum of one window for every 150 square feet of wall surface area.
(Do not recompute the area here—it was already done in calc_area.) (Hint: the answer certainly must be an even number of windows!)

Plan on installing as many windows as possible. For every window, subtract 18 square feet of area, then calculate the final paint requirements as in Program #2: 1 gallon covers 350 square feet.

After computing all the requirements, display the final painting plan for the house: the total wall surface area to be painted; number of windows to be installed; and number of gallons of paint required. In this program you must be realistic about your answers: if, for example, you calculate 4.7 windows, then certainly only 4 windows are allowed; and if you determine that 5.2 gallons of paint are needed, then 6 gallons must be purchased!

Save your program as: prog3-ii.cpp, where the letters “ii” are replaced by your own initials.