Answer to Question #62538 in C++ for Paul Luevano
a program that calculates the cost of lumber for an order
1
2016-10-14T13:49:03-0400
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main()
{
int select;
float w, h, l; // width, height, length
float qnt; // in board feet
cout << "Select the sort of lumber (prices per board foot): " << endl;
cout << "1. Pine ($1.25)" << endl;
cout << "2. Fir ($2.03)" << endl;
cout << "3. Cedar ($3.78)" << endl;
cout << "4. Maple ($1.05)" << endl;
cout << "5. Oak ($5.25)" << endl;
cin >> select;
cout << "Enter the length in feet: ";
cin >> l;
cout << "Enter the height in inches: ";
cin >> h;
cout << "Enter the width in inches: ";
cin >> w;
qnt = (l*(h/12)*(w/12)) * 12;
if(qnt < 0)
{
cout << "Error!" << endl;
exit(1);
}
switch(select)
{
case 1:
cout << "Cost of pine: $" << qnt * 1.25 << endl;
break;
case 2:
cout << "Cost of fir: $" << qnt * 2.03 << endl;
break;
case 3:
cout << "Cost of cedar: $" << qnt * 3.78 << endl;
break;
case 4:
cout << "Cost of maple: $" << qnt * 1.05 << endl;
break;
case 5:
cout << "Cost of oak: $" << qnt * 5.25 << endl;
break;
default:
cout << "Error!";
exit(1);
}
return 0;
}
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!
Learn more about our help with Assignments:
C++
Comments
Leave a comment