Write a program that calculates the cost of building a desk
Rewrite the Desks program from Exercise 7, passing all variables as reference variables and changing all the function return types to void. Save the file as Desks2.cpp.
Exercise 7:
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.
Â
Answers
Status NEW
Posted 22 May 2017 08:05 AM
My Price 5.00
-----------
Attachments
file 1495440607-Answer.docx preview (341 words )
R-----------ewr-----------ite----------- th-----------e D-----------esk-----------s p-----------rog-----------ram----------- fr-----------om -----------Exe-----------rci-----------se -----------7, -----------pas-----------sin-----------g a-----------ll -----------var-----------iab-----------les----------- as----------- re-----------fer-----------enc-----------e v-----------ari-----------abl-----------es -----------and----------- ch-----------ang-----------ing----------- al-----------l t-----------he -----------fun-----------cti-----------on -----------ret-----------urn----------- ty-----------pes----------- to----------- vo-----------id.----------- Sa-----------ve -----------the----------- fi-----------le -----------as -----------Des-----------ks2-----------.cp-----------p. ----------- Ex-----------erc-----------ise----------- 7:----------- W-----------rit-----------e a----------- pr-----------ogr-----------am -----------tha-----------t c-----------alc-----------ula-----------tes----------- th-----------e c-----------ost----------- of----------- bu-----------ild-----------ing----------- a -----------des-----------k. -----------The----------- ma-----------in(-----------)fu-----------nct-----------ion----------- ca-----------lls----------- fo-----------ur -----------oth-----------er -----------fun-----------cti-----------ons-----------. P-----------ass----------- al-----------l v-----------ari-----------abl-----------es -----------so -----------tha-----------t t-----------he -----------fun-----------cti-----------ons----------- ma-----------ke -----------cop-----------ies----------- of----------- an-----------y v-----------ari-----------abl-----------es -----------the-----------y r-----------ece-----------ive-----------: -----------» -----------A f-----------unc-----------tio-----------n t-----------o a-----------cce-----------pt -----------as -----------inp-----------ut -----------fro-----------m t-----------he -----------key-----------boa-----------rd -----------the-----------
Not Rated(0)