Im getting a message illegal else without matching if, im using the if else ladder, i have put the opening and closing bracket on every condition, but nothing seems to change...can someone explain to me on what should i do...thanks a lot!
# include <iostream>
using namespace std;
int main()
{
int hc=50; // price for hair cut
int cp=500; // price for cellophane
int ho=150; // price for hot oil
int hs=250; // price for hair spa
int hr=1500;
int hd=250;
int ham=500;
int fs=80;
int mc=60;
int pc=80;
char Y,mem;
int tot=0;
cout<<"Did the customer avail the following services:(Y/N):"<< endl;cout << "total: " << tot<<endl;
cout<<"HairCut P 50.00: ";cin>>Y;
if (hc=='Y'){
tot=hc+tot;cin>>tot;}
cout<<"HotOil P 150.00: ";cin>>Y;
else if(ho=='Y'){
tot=ho+tot;cin>>ho;}
cout<<"HairSpa P 250.00: ";cin>>Y;
else if(hs=='Y'){
cin>>hs;
tot=hs+tot;}
cout<<"Cellophane P 500: ";cin>>Y;
else if(cp=='Y'){
tot=cp+tot;cin>>cp;}
cout<<"HairRebond P 1500.00: ";cin>>Y;
else if(hr=='Y'){
cin>>hr;
tot=hr+tot;}
cout<<"HairDye P 400.00: ";cin>>Y;
else if(hd=='Y'){
tot=hd+tot;cin>>hd;}
cout<<"Hair and Makeup P 500.00: ";cin>>Y;
else if(ham=='Y'){
tot=ham+tot;cin>>ham;}
cout<<"FootSpa P 80.00: ";cin>>Y;
else if(fs=='Y'){
tot=fs+tot;cin>>fs;}
cout<<"Manicure P 50.00: ";cin>>Y;
else if(mc=='Y'){
tot=mc+tot;cin>>mc;}
cout<<"Pedicure P 60.00: ";cin>>Y;
else if(pc=='Y'){
tot=pc+tot;cin>>pc;}
else {
cout<<"Aborted";
}
return 0;
}
that is the code and i still dont know whats wrong with my if else condition!
if(...)
{
// code block
}
// Can not have any code here, else must follow on from if
// So your cout statments need to be moved
elseif(...)
{
// code block
}
else
{
// code block
}
-=# NOTICE #=-
This post has been posted twice with different titles, please follow the link below to continue the thread.
http://www.cplusplus.com/forum/beginner/2442/