Code:
if (totalsales < 100 && totalsales > 1.00); <------ error 1
{
{ < ---- Error 2
comission = totalsales * .05;
}
else
if
{ <----- Error 3:
(totalsales >= 100 && totalsales < 300); <----- error 4
{
totalsales * .10 = comission;
}
else
(totalsales >=300)
comission = totalsales * .15;
}
}
What you probably want is:
Code:
if (totalsales < 100 && totalsales > 1.00)
comission = totalsales * .05;
else
if(totalsales >= 100 && totalsales < 300)
totalsales * .10 = comission;
else
comission = totalsales * .15;
That should work. Your braces are wrong and you are including comments (total sales > 300 etc) within else statements, else statements do not contain logic, they simply are the "all others case".
If you want to use braces, you shouldn't need to however, an if statement without braces automatically includes the next line (in this case an if statement such that we have multiple lines), this would be wrong:
Code:
if (some condition)
Statement1;
Statement2;
is equivalent to:
Code:
if (some condition)
{
Statement1;
}
Statement2;
Code:
if (totalsales < 100 && totalsales > 1.00)
{
comission = totalsales * .05;
} else
{
if(totalsales >= 100 && totalsales < 300)
{
totalsales * .10 = comission;
} else
{
comission = totalsales * .15;
}
}