Question
#include #include #include 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
#include
#include
#include
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 " < break; case 'F': cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Fir " < break; case 'C': cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Ceader " < break; case 'M' : cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Maple " < break; case 'O' : cout << bNumb << " " << bWide << "x" << bHigh << "x" << bLong << " " << " Oak " < 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." < } 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; } How can I fix this to where "T" or "t" will show total?
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started