So our instructor gave as an exercise where a user inputs a number and if the input number is greater than 1000, it'll compute this. But, there's a maximum number which is 3200, if it exceeds that number, it shouldn't compute the formula..
Here's the problem:
SALE VALUE Commission
up to 100 --- 0
over 100-1000 -- 2 %
over 1000 -- 3%
maximum is 3200
#include <iostream.h>
int main ()
{
float c, sv;
cout <<"Enter sale value:";
cin >> sv;
if (sv <= 100)
c= 0;
elseif (sv >= 100)
c = sv * .02;
elseif (sv > 1000 && sv < 3200)
c = sv *.03;
cout <<"" << endl;
cout <<"Your commision is " << c << endl;
return 0;
}
My instructor said that it's wrong since when I entered 3201 and 3202, the results were different in which it should be different.
But I used the logical &&. What might be the problem?
I have fixed your problem. Now if you input number greater than 3200. It will display message and for number less than 3200 you will have correct output.