Problem

Rewrite the Desks program from Exercise, passing all variables as reference variables and...

Rewrite the Desks program from Exercise, passing all variables as reference variables and changing all the function return types to void. Save the file as Desks2.cpp.

Exercise

Write a program that calculates the cost of building a desk. The main()function calls four other functions. Pass all variables so that the functions make copies of any variables they receive:

» A function to accept as input from the keyboard the number of drawers in the desk. This function returns the number of drawers to the main program.

» A function to accept as input the type of wood—‘m’ for mahogany, ‘o’ for oak, or ‘p’ for pine.

» A function that receives the drawer number and wood type, and calculates the cost of the desk based on the following:

Pine desks are $100.

Oak desks are $140.

All other woods are $180.

A $30 surcharge is added for each drawer.

This function returns the cost to the main()function.

» A function to display the final price.

Save the file as Desks.cpp.

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT