1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97
|
#include <iostream>
#include <fstream>
using namespace std;
float bCalculation(char bType,float& bNumb,float& bWide,float& bHigh,float& bLong,float& tCost,float total);
void bTotal(char bType, float& total, float tCost);
int main()
{
char bType;
float bNumb;
float bWide = 0;
float bHigh = 0;
float bLong = 0;
float tCost = 0;
float total =0;
do
{
cout << "Enter Wood Type" << endl
<< "P = Pine," << " F = Fir," << " C = Ceder," << " M = Maple,"
<< " O = Oak," << " T = Total Price" << endl;
cin >> bType;
if(toupper(bType) == 'T')
{
bTotal(bType,total,tCost);
}
cout << endl << "Enter Amount, Width (in), Height(in), Length(ft),seperated by space" << endl;
cin >> bNumb >> bWide >> bHigh >> bLong;
cout << endl;
while (bNumb <= 0 || bWide <= 0 || bHigh <= 0 || bLong <= 0)
{
cout <<"Incorrect Input, Plese enter number of Pieces, Width, Height,Length" << endl;
cin >> bType >> bNumb >> bWide >> bHigh >> bLong;
cout << endl;
}
bCalculation(bType,bNumb,bWide,bHigh,bLong,tCost,total);
switch(toupper(bType))
{
case 'P':cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Pine " << tCost << endl ;
break;
case 'F':cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Fir " << tCost << endl ;
break;
case 'C':cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Ceader " << tCost << endl ;
break;
case 'M' :cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Maple " << tCost << endl ;
break;
case 'O' :cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Oak " << tCost << endl ;
break;
case 'T':
default :cout << "Incorrect Input, Please use letter (P, F, C, M, O) for wood type,or T for totla." <<endl;
}
}while(bNumb,bWide, bHigh, bLong );
return 0;
}
void bTotal(char bType,float& total,float tCost)
{
tCost= total;
total = total + tCost;
cout << "total" << total;
}
float bCalculation(char bType,float& bNumb,float& bWide,float& bHigh,float& bLong,float& tCost,float total)
{
float tMessure;
float sCost;
float bPrice =0;
if(toupper(bType) == 'P')
bPrice = 0.89;
if(toupper(bType) == 'F')
bPrice = 1.09;
if(toupper(bType) == 'C')
bPrice = 2.26;
if(toupper(bType) == 'M')
bPrice = 4.50;
if(toupper(bType) == 'O')
bPrice = 3.10;
tMessure = bWide * bHigh *(bLong * 12);
cout << tMessure << endl;
sCost = (tMessure / 144)* bPrice;
cout << sCost << endl;
tCost = sCost * bNumb;
return tCost;
}
|