Blackboard 4G 2:21 PM * 100% CS 317 Lumber Order You are to write a program to c
ID: 3698709 • Letter: B
Question
Blackboard 4G 2:21 PM * 100% CS 317 Lumber Order You are to write a program to compute the cost of a lumber order for a local lumber company The company sells pine, fir, cedar, maple and oak lumber and the lumber is priced by board feet'. One board foot equals one square foot, one inch thick. The price per board foot is given in the following table Pine 1.05 Fir 1.29 Cedar 2.25 Maple 4.10 Oak 2.40 The lumber is sold in different dimensions (specified in inches for width and height, and feet for length) that need to be converted to board feet. For ex, a 2 x 4 x 8 piece is 2 inches wide, 4 inches high and 8 feet long, and is equivalent to S.333 board feet The input will be for several customers, each with a lumber order. The lumber order will have Input file: LumberOrder.txt The input format for an order will be first: a label Customer #:, followed by the customer's ID several types of woods and different sizes in each order. number. The next lines contain the lumber onder, starting with a letter (P, F. C.M. O) corresponding to the five kinds of wood) or a T meaning following the T. The program should print out each entry (itemized the order) and print out the total cost of the order. You must use Functions. One to read the data, one to compute board feet, one to compute cost, one to print a line of output (maybe more output functions.) total. When the letter is a T. there will be no other numbers Example input Customer #: 1020 P 10 248 M3 16 10 Pine 10 pieces 2 inches by 4 inches by 8 feet Maple 3 picces I iss by 6 inches by 10 foct Flag for the program to print the total cost of this order Customer #: 2040 new wood order for next customer. Output Customer Order Report Customer 1020 Pieces SizeWood Cost $47.47 Ix6x10 Maple$11.25 10 2x4x Pine Total: $1340.28 Customer # 2040Explanation / Answer
Code
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
float bf(int, int , int );
int main () {
float lumber_cost = 0;
float total = 0;
string lumbertype;
float lumber_total;
float board_Feet;
char lumber_Type;
int quantity;
int width;
int height;
int length;
cout << fixed << setprecision(2);
cout << "You will be entering your order by type, quantity, width, height, and length. "
<< " An example order is: C 8 2 4 8 "<< endl <<"Please use this format for orders."
<< endl << endl;
cout << "By entering T in the order line, total cost of all orders will be displayed." << endl
<< "Enter your order: ";
cin >> lumber_Type;
if(toupper(lumber_Type) == 'T')
return 0;
cin >> quantity;
cin >> width;
cin >> length;
cin >> height;
while (!(toupper(lumber_Type) == 'T')) {
if (toupper (lumber_Type) == 'F') {
lumber_cost = 1.29; lumbertype = "Fir";
}
else if (toupper (lumber_Type) == 'P') {
lumber_cost = 1.05; lumbertype = "Pine";
}
else if (toupper (lumber_Type) == 'C') {
lumber_cost = 2.25;
lumbertype = "Cedar";
}
else if (toupper (lumber_Type) == 'M') {
lumber_cost = 4.10;
lumbertype = "Maple";
}
else if ( toupper(lumber_Type) == 'O') {
lumber_cost = 2.40;
lumbertype = "Oak";
}
else {
cout << lumber_Type << " " << "is not a lumber type" << endl;
cout << "Please enter a valid lumber type with order." << endl;
cin.clear();
}
board_Feet = bf(width, height, length);
total += board_Feet * lumber_cost * quantity;//calculates the total cost untill we entered T or t
cout << quantity << " "<< length << "x" << width << "x" << height << " " << lumbertype << ", cost: $"<< board_Feet * lumber_cost * quantity << endl;
cout << " Enter your order: ";
cin >> lumber_Type;
if (toupper(lumber_Type) == 'T') {
cout << "Total cost: $" << total << endl;
}
else {
cin >> quantity;
cin >> width;
cin >> length;
cin >> height;
}
}
system ("pause");
return 0;
}
float bf ( int width, int height, int length) {
float squareFeet;
float boardfeet;
squareFeet = (length * width) / 12.0;
boardfeet = squareFeet * height;
return boardfeet;
}
If any queries regarding code and execution please get back to me
Thank You
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.