The template shown below must be incorporated into the code showed after the template   Template: // -- brief statement as to the file’s purpose //XXX XXX- ADD YOUR SECTION NUMBER //Include statements #include #include using namespace std; //Global declarations: Constants and type definitions only -- no variables //Function prototypes int main() { //In cout statement below SUBSTITUTE your name and lab number cout << "Your name -- Lab Number" << endl << endl; //Variable declarations //Program logic //Closing program statements system("pause"); return 0; } //Function definitions

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section: Chapter Questions
Problem 8PP: (Data processing) A bank’s customer records are to be stored in a file and read into a set of arrays...
icon
Related questions
Question

The template shown below must be incorporated into the code showed after the template

 

Template:

// -- brief statement as to the file’s purpose

//XXX XXX- ADD YOUR SECTION NUMBER

//Include statements

#include

#include

using namespace std;

//Global declarations: Constants and type definitions only -- no variables

//Function prototypes

int main()

{

//In cout statement below SUBSTITUTE your name and lab number

cout << "Your name -- Lab Number" << endl << endl;

//Variable declarations

//Program logic

//Closing program statements

system("pause");

return 0;

}

//Function definitions

 

Code:

 

#include<iostream>
#include <iomanip>

using namespace std;

//function prototypes
float convToFeet(float, float, float);

//main function
int main()

{
// variable declaration
char woodType;
float totalCharge = 0.0, eachCost = 0.0, woodWidth, woodHeight, woodLength;;
int noOfpc;
cout << setprecision(2) << fixed;

//infinite loop until it obtains the character 'T'
do
{
cout << "\nEnter item: ";
cin >> woodType;// get the input(char type) from the user
if (woodType != 'T')
{
//read all required values
cin >> noOfpc >> woodWidth >> woodHeight >> woodLength;
//compute the charge
switch (woodType)
{
case 'P':
eachCost = (0.89 * noOfpc * convToFeet(woodWidth, woodHeight, woodLength));
cout << noOfpc << " " << woodWidth << "x" << woodHeight << "x" << woodLength
<< " " << "Pine," << " cost: " << "$" << eachCost << " ";
break;

case 'F':
eachCost = (1.09 * noOfpc * convToFeet(woodWidth, woodHeight, woodLength));
cout << noOfpc << " " << woodWidth << "x" << woodHeight << "x" << woodLength
<< " " << "Fir," << " cost: " << "$" << eachCost << " ";
break;

case 'C':

eachCost = (2.26 * noOfpc * convToFeet(woodWidth, woodHeight, woodLength));
cout << noOfpc << " " << woodWidth << "x" << woodHeight << "x" << woodLength
<< " " << "Cedar," << " cost: " << "$" << eachCost << " ";
break;

case 'M':

eachCost = (4.50 * noOfpc * convToFeet(woodWidth, woodHeight, woodLength));
cout << noOfpc << " " << woodWidth << "x" << woodHeight << "x" << woodLength
<< " " << "Maple," << " cost: " << "$" << eachCost << " ";
break;

case 'O':

eachCost = (3.10 * noOfpc * convToFeet(woodWidth, woodHeight, woodLength));
cout << noOfpc << " " << woodWidth << "x" << woodHeight << "x" << woodLength
<< " " << "Oak," << " cost: " << "$" << eachCost << " ";
break;
}
//add the running total
totalCharge += eachCost;
}
//exit getting the character 'T'
else
{
//print required values
cout << "Total cost: $" << totalCharge << " ";
break;

}

} while (woodType != 'T');
///main returns 0 after successful completion of the program.
return 0;
}

//describe 'convToFeet'
float convToFeet(float width, float height, float length)
{
float ft = ((width*height*length) / 12.0);
return ft;
}

 

 

Expert Solution
Step 1

Computer Science homework question answer, step 1, image 1

The code incorporated with the template given above is as follows:

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Mathematical functions
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr