Its a pretty long code i know, but i need help. It would probably be best for you to make a project and compile it in your enviorment and see what im talking about error wise. In the end day report, It is supposed to put how many cans each state has had since the program started running. My program is defaulting to GA/FL no matter what state i put it in. I think it has to do with my code in performsalescalc and PerformCalc. Any help would be appreciated I am a begginner so use easy terminology Thanks in adavance if (_stricmp (sState,"GA")) Code: /*-------------------------FUNCTION PROTOTYPES----------------------------------------------------------*/ void GetRoomDimensions(void); void PerformCalc(void); void PerformSalesCalc(void); //tc prototype void PrintOutput(void); void GetName(void); void RepeatCode (void); void LoopQuestion (void); void DisplayHeader(void); void Dashes(void); void SalesDayScreen (void); void Center (char *s); void EndReport (void); void MainMain(void); /*-----------------------Global Variables--------------------------------------------------------------*/ //input variables float Flength; float Fwidth; float Fheight; char sCname[25]; char sRepeat; char sSales='Y'; char sState[3]; //Calculated Data float Farea; // = wall 1 + wall 2 float Fwall1; // Length * Height *2 float Fwall2; // Width * Height *2 float Fareagallon; // Amount of area a gallon will cover float Fgallons; // Total Number of gallons it will take to paint float Fbeforediscount; //before discount float Fafterdiscount; //After discount float Ftax; //With Tax float Fcostper; //Cost per gallon of paint float Famountoff; //amount off discount float Ftaxadded; //amount added to cost float GaCans; // Number of cans sold in Ga float FlCans; // Number of cans sold in FL float ScCans; // Number of cans sold in SC float TnCans; // Number of cans sold in Tn float AlCans; // Number of cans sold in AL float OCans; // Number of cans sold in Other States float GaTotCost; // Total cost of can sold in Ga float FlTotCost; // Total cost of can sold in FL float ScTotCost; // Total cost of can sold in SC float TnTotCost; // Total cost of can sold in TN float AlTotCost; // Total cost of can sold in AL float OTotCost; // Total Cost of cans sold in other states float TotalCans; //Total Number of Cans for every state added up float TotalCanPrice; //total prices of all cans /*--------------------Main Module------------------------------------------------------------------*/ int main () { SalesDayScreen(); MainMain(); system("pause"); return 0; } /*----------------------------------------------------------------------------------------------------- Name: SalesDayScreen Desc: Asks user if it is a sales day Return: Void Parameters: Void ---------------------------------------------------------------------------------------------------*/ void SalesDayScreen (void) { DisplayHeader(); Center("Acme Paint Shop - Sales Day Question"); Dashes(); cout<<"Is it a sales day (Y/N)?"; cin>>sSales; cin.ignore(); return; } /*----------------------------------------------------------------------------------------------------- Name: GetName Desc: Gets Name Return: Void Parameters: Void ---------------------------------------------------------------------------------------------------*/ void GetName (void) { cout<<"Enter the customer's first and last name?"; cin.getline(sCname, 25); return; } /*----------------------------------------------------------------------------------------------------- Name: GetRoomDimensions Desc: Gets Room Dimensions Return: Void Parameters: Void ---------------------------------------------------------------------------------------------------*/ void GetRoomDimensions(void) { DisplayHeader(); Center("Acme Paint Shop - Input"); Dashes(); GetName(); cout<<endl; cout<<"What is the length of the room in feet?"; cin>> Flength ; cout<<endl; cout<<"What is the width of the room in feet?"; cin>>Fwidth; cout<<endl; cout<<"What is the height of the room in feet?"; cin>>Fheight; cout<<endl; cout <<"What is the area covered by a gallon of paint?"; cin>>Fareagallon; cout<<endl; cout <<"What is the cost of paint per gallon?"; cin >> Fcostper; cout<<endl; cout<<endl; if ((Fcostper >= 1) && (Fcostper <= 50)) { cout<<"What state are you located?"; cin>>sState; cout<<endl; return; } else { cout <<"Error: Please enter a numeric value between 1 - 50!"; cout<<endl; cout<<endl; cout<<"What is the cost of paint per gallon?"; cin >> Fcostper; cout<<endl; cout<<"What state are you located?"; cin>>sState; cout<<endl; return; } return; } /*--------------------------------------------------------------------------------------------------------- Name:PerformCalc Desc:Calculate Area Return: Void Parameters:Void ----------------------------------------------------------------------------------------------------------*/ void PerformCalc (void) { Fwall1 = (Flength * Fheight)* 2; Fwall2 = (Fwidth * Fheight) * 2; Farea = (Fwall1+ Fwall2); Fgallons = Farea/Fareagallon; Fbeforediscount = ceil(Fgallons) * Fcostper; //TAX SECTION if (_stricmp (sState,"GA")) { Ftaxadded = Fbeforediscount * 0.06f; } else if (_stricmp (sState,"FL")) { Ftaxadded=Fbeforediscount*0.04f; } else if (_stricmp (sState,"SC")) { Ftaxadded=Fbeforediscount*0.05f; } else if (_stricmp (sState,"TN")) { Ftaxadded=Fbeforediscount*0.06f; } else if (_stricmp (sState,"AL")) { Ftaxadded=Fbeforediscount*0.02f; } Ftax=Ftaxadded+Fbeforediscount; //Adding up State Gallons if (_stricmp (sState,"GA")) { GaCans=Fgallons; } else if (_stricmp (sState,"FL")) { FlCans = Fgallons; } else if (_stricmp (sState,"SC")) { ScCans=Fgallons; } else if (_stricmp (sState,"TN")) { TnCans=Fgallons; } else if (_stricmp (sState,"AL")) { AlCans=Fgallons; } //Total Cost Of Paint Per State if (_stricmp (sState,"GA")) { GaTotCost= Ftax; } else if (_stricmp (sState,"FL")) { FlTotCost=Ftax; } else if (_stricmp (sState,"SC")) { ScTotCost=Ftax; } else if (_stricmp (sState,"TN")) { TnTotCost= Ftax; } else if (_stricmp (sState,"AL")) { AlTotCost=Ftax; } return; } /*--------------------------------------------------------------------------------------------------------- Name:PerformSalesCalc Desc:Calculate Area Return: Void Parameters:Void ----------------------------------------------------------------------------------------------------------*/ void PerformSalesCalc (void) { Fwall1 = (Flength * Fheight)* 2; Fwall2 = (Fwidth * Fheight) * 2; Farea = (Fwall1+ Fwall2); Fgallons = Farea/Fareagallon; Fbeforediscount = ceil(Fgallons) * Fcostper; if (Fgallons==1) { Famountoff = Fcostper * .05f; } else if (Fgallons <=3 && Fgallons >=2) { Famountoff = Fcostper * .10f; } else if (Fgallons == 4) { Famountoff = Fcostper * .15f; } else if (Fgallons >=5) { Famountoff = Fcostper * .25f; } Fafterdiscount=ceil(Fgallons)* (Fcostper-Famountoff); //State Tax if (_stricmp (sState,"GA")) { Ftaxadded=Fafterdiscount*0.06f; } else if (_stricmp (sState,"FL")) { Ftaxadded=Fafterdiscount*0.04f; } else if (_stricmp (sState,"SC")) { Ftaxadded=Fafterdiscount*0.05f; } else if (_stricmp (sState,"TN")) { Ftaxadded=Fafterdiscount*0.06f; } else if (_stricmp(sState,"AL")) { Ftaxadded=Fafterdiscount*0.02f; } Ftax=(Ftaxadded+Fafterdiscount); //Adding up State Gallons if (_stricmp (sState,"GA")) { GaCans=Fgallons; } else if (_stricmp (sState,"FL")) { FlCans=Fgallons; } else if (_stricmp (sState,"SC")) { ScCans=Fgallons; } else if (_stricmp (sState,"TN")) { TnCans= Fgallons; } else if (_stricmp (sState,"AL")) { AlCans=Fgallons; } //Total Cost Of Paint Per State if (_stricmp (sState,"GA")) { GaTotCost=Ftax; } else if (_stricmp (sState,"FL")) { FlTotCost=Ftax; } else if (_stricmp (sState,"SC")) { ScTotCost= Ftax; } else if (_stricmp (sState,"TN")) { TnTotCost= Ftax; } else if (_stricmp (sState,"AL")) { AlTotCost= Ftax; } return; } /*----------------------------------------------------------------------------------------------------------- Name:PrintOutput Desc:Display Output on Monitor Return:Void Parameter: Void ------------------------------------------------------------------------------------------------------------*/ void PrintOutput (void) { DisplayHeader(); Center("Acme Paint Shop - Single Customer Calculation"); Dashes(); cout <<endl; cout<<"Customer Name (first and last):"<<sCname; cout<<endl; cout <<"Number of gallons needed: "; cout <<ceil(Fgallons); cout <<endl; if (sSales=='N') { cout<<"Cost before discount $"; cout <<Fbeforediscount; cout<<endl; cout <<"Cost after discount $"; cout <<Fbeforediscount; cout << endl; cout<<"Cost with Tax $"; cout<<Ftax; cout<<endl; } else { cout <<"Cost before discount $"; cout <<Fbeforediscount; cout << endl; cout<<"Cost after discount $"; cout <<Fafterdiscount; cout<<endl; cout<<"Cost with Tax $"; cout<<Ftax; cout<<endl; } return; } /*----------------------------------------------------------------------------------------------------- Name: RepeatCode Desc: Code Inside Loop Return: Void Parameters: ---------------------------------------------------------------------------------------------------*/ void RepeatCode () { DisplayHeader(); Center("Acme Paint Shop - Input"); Dashes(); MainMain(); return; } /*----------------------------------------------------------------------------------------------------------- Name:Loop Desc:Loops Program Return:Void Parameter: Void ------------------------------------------------------------------------------------------------------------*/ void LoopQuestion (void) { cout<<endl; cout <<"Do you want to continue (Y/N)?"; cin >>sRepeat; sRepeat = toupper(sRepeat); system("cls"); cin.ignore(); return; } /*----------------------------------------------------------------------------------------------------------- Name:Display Header Desc:Display Header Return:Void Parameter: Void ------------------------------------------------------------------------------------------------------------*/ void DisplayHeader (void) { system("cls"); Dashes(); return; } /*----------------------------------------------------------------------------------------------------------- Name:Dashes Desc:Displays Dashes Return:Void Parameter: Void ------------------------------------------------------------------------------------------------------------*/ void Dashes (void) { int iCounter=0; for(iCounter = 0; iCounter <=79; ++iCounter) cout<< "*"; return; } /*----------------------------------------------------------------------------------------------------------- Name:Center Desc:Centers Text ------------------------------------------------------------------------------------------------------------*/ void Center(char *s) { int len; len = 42+(strlen(s)/2); cout.width(len); cout << s << '\n'; } /*----------------------------------------------------------------------------------------------------------- Name:EndReport Desc:Shows End report Return:Void Parameter: Void -----------------------------------------------------------------------------------------------------------*/ void EndReport (void) { DisplayHeader(); Center("Acme Paint Shop - End Report"); Dashes(); cout << "State # of Cans Total Cost "; cout<<endl; cout << "GA " << setprecision(0) << fixed << GaCans << " $" << GaTotCost << endl; cout << "FL " << setprecision(0) << fixed << FlCans << " $" << FlTotCost << endl; cout << "SC " << setprecision(0) << fixed << ScCans << " $" << ScTotCost << endl; cout << "TN " << setprecision(0) << fixed << TnCans << " $" << TnTotCost << endl; cout << "AL " << setprecision(0) << fixed << AlCans << " $" << AlTotCost << endl; cout << "Other " << setprecision(0) << fixed << OCans << " $" << OTotCost << endl; cout<<"_______________________________________________________________________________"; cout<<endl; cout<<"Grand Total "<< TotalCans<<" $"<<TotalCanPrice << endl; cout<<"Customer With highest total after tax:"<< endl; return; } /*----------------------------------------------------------------------------------------------------------- Name:Main Main Desc:Holds the Main Portion of the Code Return:Void Parameter: Void ------------------------------------------------------------------------------------------------------------*/ void MainMain (void) { system("cls"); GetRoomDimensions(); if (sSales=='Y') { PerformSalesCalc(); } PerformCalc(); PrintOutput(); LoopQuestion(); if (sRepeat=='Y') { RepeatCode(); } EndReport(); return; }
Code: char str[32]; strcpy(str,"Hello"); if (strcmp(str,"Hello")) { printf("Do you think this message will be displayed?\n"); } if (!strcmp(str,"Hello")) { printf("What about this message?\n"); }