A non zero value with no logical or relational operators in a boolean condition will always return true. So "a"
in first if
will always return true
.That's why only the first if
gets executed all the time. Modify you if-else-if as given below:
if(ID =="A"||ID == "a"){
com=(sal_val*4.5)/100;
cout<<"Commission for Apple Rs. " <<com<<endl;}
else if(ID =="B"||ID == "b"){
com=(sal_val*5)/100;
cout<<"Commission for Banana Rs. " <<com<<endl;}
else if(ID =="O"||ID == "o"){
com=(sal_val*5.5)/100;
cout<<"Commission for Orange Rs. " <<com<<endl;}
else if(ID =="G"||ID == "g"){
com=(sal_val*6)/100;
cout<<"Commission for Grapes Rs. " <<com<<endl;}
For comparing a variable with multiple values individual conditions needs to be written in code as written for each of if-else-if construct.