Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

(Program in C++) >>> Copy & Paste Code Below #include #include #include using namespace std; const double INCHESINLINEARFOOT = 12.0; const double INCHESINONESQUAREFOOT = 144.0;

(Program in C++)

image text in transcribed

image text in transcribed

image text in transcribed

>>> Copy & Paste Code Below

#include

#include

#include

using namespace std;

const double INCHESINLINEARFOOT = 12.0;

const double INCHESINONESQUAREFOOT = 144.0;

const double PINECOST = 0.89;

const double FIRCOST = 1.09;

const double CEDARCOST = 2.26;

const double MAPLECOST = 4.40;

const double OAKCOST = 3.10;

bool validateType(char t);

// Return true if t represents a valid wood type or false otherwise

double calcBoardFeet(double th, double wid, double len);

// calculate board feet where th = thickness in inches,

// wid = width in inches and len = length in feet

double calcCost(char type, int numP, double bf);

// calculate cost based on type, number of pieces and board feet

string getTypeName(char type);

// return name of wood type based on char representing type, eg P = Pine

void getData(char & woodType, int & numPieces, double &thickness, double & width, double & length);

// Get data on sale

int main()

{

char woodType, reply;

int numPieces;

double thickness, width, length;

double cost, totalCost, boardFeet;

string woodTypeName;

cout

do

{

totalCost = 0;

do

{

getData(woodType, numPieces, thickness, width, length);

if (woodType != 'T')

{

boardFeet = calcBoardFeet(thickness, width, length);

cost = calcCost(woodType, numPieces, boardFeet);

woodTypeName = getTypeName(woodType) + ", cost: $";

cout " X " " X " " "

totalCost+= cost;

}

}while (toupper(woodType) != 'T');

cout "Total cost: $"

cout "More purchases?"

cin >> reply;

}while (toupper(reply) == 'Y');

}

//Function definitions here:

Purpose: This experiment is designed to develop confidence with functions Readings: This experiment focuses upon the material covered up through chapter 6 of our text Instructions: A lumber company needs a program to calculate the cost of lumber for an order. company sells pine, fir, cedar, maple and oak lumber. All lumber is priced per board foot. One board foot is equal to one square foot one inch thick. The price per board foot is: Pine $0.89 Fir 1.09 Cedar 2.26 Maple 4.40 Oak 3.10 The lumber is sold in different dimensions (specified in inches of width and thickness, and feet of length) which need to be converted to board feet. For example a piece of wood 2 X 4 X 8 is 2 inches thick, 4 inches wide and 8 feet long. That is equivalent to 5.333 board feet. The user will enter the type of lumber (P, F, C, M or O) and an integer and three doubles indicating the number of pieces, thickness, width and length, or T indicating the order should be totaled. A typical run might be: Enter item: i I is not a valid type! Reenter Enter number of pieces and thickness width and length 100 2.5 3 20 100 2.50 X 3.00 X 20.00 Oak, cost: $3875.00 Enter item: p Enter number of pieces and thickness width and length 150 3 3.5 22 150300 X 3.50 X 22.00 Pine, cost: $2569.88 Enter item: t Total cost: $6444.88 More purchases? Ive given you the program with the function prototypes and the code for main. You need to write the function definitions Purpose: This experiment is designed to develop confidence with functions Readings: This experiment focuses upon the material covered up through chapter 6 of our text Instructions: A lumber company needs a program to calculate the cost of lumber for an order. company sells pine, fir, cedar, maple and oak lumber. All lumber is priced per board foot. One board foot is equal to one square foot one inch thick. The price per board foot is: Pine $0.89 Fir 1.09 Cedar 2.26 Maple 4.40 Oak 3.10 The lumber is sold in different dimensions (specified in inches of width and thickness, and feet of length) which need to be converted to board feet. For example a piece of wood 2 X 4 X 8 is 2 inches thick, 4 inches wide and 8 feet long. That is equivalent to 5.333 board feet. The user will enter the type of lumber (P, F, C, M or O) and an integer and three doubles indicating the number of pieces, thickness, width and length, or T indicating the order should be totaled. A typical run might be: Enter item: i I is not a valid type! Reenter Enter number of pieces and thickness width and length 100 2.5 3 20 100 2.50 X 3.00 X 20.00 Oak, cost: $3875.00 Enter item: p Enter number of pieces and thickness width and length 150 3 3.5 22 150300 X 3.50 X 22.00 Pine, cost: $2569.88 Enter item: t Total cost: $6444.88 More purchases? Ive given you the program with the function prototypes and the code for main. You need to write the function definitions

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions

Question

What is Constitution, Political System and Public Policy? In India

Answered: 1 week ago

Question

What is Environment and Ecology? Explain with examples

Answered: 1 week ago

Question

8. Explain the contact hypothesis.

Answered: 1 week ago

Question

2. Define the grand narrative.

Answered: 1 week ago