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
|
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
float bCalculation(char bType, int& bNumb, int& bWide, int& bHigh, int& bLong,float& tCost,float total);
void bTotal(char bType, float& total, float tCost);
int main()
{
char bType;
int bNumb;
int bWide = 0;
int bHigh = 0;
int bLong = 0;
float tCost = 0;
float total = 0;
do
{
cout << "Enter item: ";
cin >> bType>> bNumb >> bWide >> bHigh >> bLong;
if(bType != 'T'||bType != 't')//I changed this up a bit//
{
while (bNumb <= 0 || bWide <= 0 || bHigh <= 0 || bLong <= 0)
{
cout <<"Incorrect Input, Plese enter type, number of Pieces, Width, Height,Length" << endl;
cin >> bType >> bNumb >> bWide >> bHigh >> bLong;
cout << endl;
}
total = total + bCalculation(bType,bNumb,bWide,bHigh,bLong,tCost,total); //here is where I assign it to total//
switch(toupper(bType))
{
case 'P': cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " <<
" Pine " << fixed << setprecision(2) << tCost << endl ;
break;
case 'F': cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " <<
" Fir " << fixed << setprecision(2) << tCost << endl ;
break;
case 'C': cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " <<
" Ceader " << fixed << setprecision(2) << tCost << endl ;
break;
case 'M' : cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " <<
" Maple " << fixed << setprecision(2) << tCost << endl ;
break;
case 'O' : cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " <<
" Oak " << fixed << setprecision(2) << tCost << endl ;
break;
case 'T': cout << "Total cost: "<< fixed << setprecision(2) << tCost << endl;
break;
default :cout << "Incorrect Input, Please use letter (P, F, C, M, O) for wood type,or T for total." <<endl;
}
cout << total << endl; // here is where I call it to the screen//
}
}while(bNumb,bWide, bHigh, bLong );
return 0;
}
float bCalculation(char bType, int& bNumb, int& bWide, int& bHigh, int& 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);
sCost = (tMessure / 12)* bPrice;
tCost = sCost * bNumb;
return tCost;
}
|