c++ won't read my else if statement for calculation

Hi, I'm having a problem at the else if statement. If I enter PT3 for the category, P for package and when I choose 'D' in if for the code of time, the calculation will choose 'D' in else if statement and proceed for the calculation and vice versa. Can anyone help me out?

if (codeOfCategory == 'P' || codeOfCategory == 'p')
{
cout<<"\n|-------------------------------------------------------------------------------------------------------------------------------------------------|";
cout<<"\n| Category | Type of | Code of | Type of | Code of | Code of Individual | Subject | Time | Code of | Price per |";
cout<<"\n| | Category | Category | Subject | Package | Subject | | | Time | package |";
cout<<"\n|-------------------------------------------------------------------------------------------------------------------------------------------------|";
cout<<"\n| | | | LANGUAGE | PTL | BMY | Bahasa Melayu | Weekdays | D | 90 |";
cout<<"\n| | | | | | ENG | English | Weekend | E | 70 |";
cout<<"\n| | | | | | SEJ | Sejarah | | | |";
cout<<"\n| PT3 | PACKAGE | P =======================================================================================================|";
cout<<"\n| | | | STEM | PTA | MAT | Mathematic | Weekdays | D | 80 |";
cout<<"\n| | | | | | SCI | Science | Weekend | E | 70 |";
cout<<"\n| | | | | | GEO | Geography | | | |";
cout<<"\n--------------------------------------------------------------------------------------------------------------------------------------------------|";

cout<<"\nPlease enter code of Package ( PTL-Language / PTA-STEM ) : ";
cin>>codeOfPackage;

if(strcmp(codeOfPackage,"PTL")==0 || strcmp(codeOfPackage,"ptl")==0)
{
cout<<"\nPlease enter code of time ( D-WEEKDAYS / E-WEEKEND ) : ";
cin>>codeOfTime;

if (codeOfTime,'D' || codeOfTime,'d')
{
price=90.00;
}
if (codeOfTime,'E' || codeOfTime,'e')
{
price=70.00;
}
else
{
price=0.00;
cout<<"\nERROR!";
}
tax = 0.06;
TpricePT3 = price + (price * tax);

PTL++;

}
else if(strcmp(codeOfPackage,"PTA")==0 || strcmp(codeOfPackage,"pta")==0)
{

cout<<"\nPlease enter code of time ( D-WEEKDAYS / E-WEEKEND ) : ";
cin>>codeOfTime;

if(codeOfTime,'D' || codeOfTime,'d')
{
price=80.00;
}
if(codeOfTime,'E' || codeOfTime,'e')
{
price=70.00;
}
else
{
price = 0.00;
}
tax = 0.06;
TpricePT3 = price + (price * tax);

PTA++;
}
else
{
price=0.00;
cout<<"\nERROR!";
}

cout<<setprecision(2)<<fixed;
cout<<"\n|---------RECEIPT OF REGISTRATION FORM-----------|";
cout<<"\n|Your code of package is ( PTL-Language / PTA-STEM ) : " <<codeOfPackage;
cout<<"\n|Your code of time is ( D-WEEKDAYS / E-WEEKEND ) : " <<codeOfTime;
cout<<"\n|Your price is : RM" <<TpricePT3;
cout<<"\n|------------------------------------------------|";
//cout<<"\nDo you want to add another registration? (Y-YES / N-NO): ";
//cin>>registration;
}




You are using commas instead of == in a few places. E.g.,

 
if (codeOfTime,'D' || codeOfTime,'d')

Assuming codeOfTime is a char it should be

 
if (codeOfTime == 'D' || codeOfTime == 'd')

what language is that from? It looks a little like how excel does conditions, but I don't know of a real language that does it that way.

I do a lot of typos due to other-language syntax. Its an occupational hazard, I guess :)
Topic archived. No new replies allowed.