cout<<"\n Input name and sales " ;
cin>>name>>sales;
if (sales<15000)com=0;//if sales is below 15t com is 0
if (sales<25000)com=sales-15000*.1+1500;
//if sales between 15t to 25t com is 1500+10% of sales that exceeds 15000
if (sales>25000)com=sales-25000*.1+1500;
//if sales is 25t up com is 3000+10% of sales that exceeds 15000
cout<<"\n the commission is " <<com;
system("PAUSE");
return 0;
}
it runs but i am not sure if the output is right... thanks in advance...
Look closely at my post. Does it say else (sales>25000) or else? It just says "else", doesn't it? else statements don't allow a condition because it wouldn't make sense. It's just the part that is executed if all the other conditions were false.
As an aside, prefer this style
1 2
if (condition)
statement;
over this style
if (condition) statement;
The first one improves readability and doesn't give the more experienced programmers the desire to smack you over the head with a C++ manual, so it's a win-win situation.
Hi,
I am Rammohan from Bangalore and working as a Technical lead in big IT firm . Solution for your answer is follows:
The way you have coded is wrong. Compiler cannot choose the sales value is in which level. You need to write the code as follows:
if (sales<=15000)
Commission=0;
else if (15000<25000)
Commission = (sales-15000)*.1+1500;
else (sales>25000)
Commission = sales-25000*.1+1500;
____________________
Regards, Rammohan Alampally,
rammohan@india.com
Technical Lead,
Bangalore, India.
www.FindSyntax.com -> Worlds first Web based Windows O/S is a Brain Chaild of Rammohan
Oh my god, what the hack should that be? It isn't april the 1st on my calendar. And the statement elseif (15000<25000)
is a code joke at best, and not even a funny one. By the way, this forum doesn't support signatures, for which I'm quite grateful. So please stop you futile attempt to create attention by putting them in manually.