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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
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
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education