Compound If Exercise
With multiple logical operators
What would be the commission rate given the following values?
|
|
intYearsEmployed |
sngSales |
sngPreviousSales |
sngCommission |
|
1) |
5 |
400,000 |
350,000 |
3% – 12,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 400,000 > 300,000 & 350,000 > 300,000 that part of the condition is True and since 5 > 5 the expression is evaluated as True OR (True) making the Condition True |
|
2) |
6 |
100,000 |
400,000 |
3% – 3,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 100,000 is NOT > 300,000 that part of the condition is False but since 6 > 5 the expression is evaluated as True OR (False) With the OR operator only one of the stated conditions must be true for the entire condition to be true making the entire condition True |
|
3) |
5 |
400,000 |
290,000 |
3% – 12,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 400,000 is > 300,000 But 290,000 is NOT > 300,000 that part of the condition is False but since 5 > 5 the expression is evaluated as True OR (False) With the OR operator only one of the stated conditions must be true for the entire condition to be true making the entire condition True |
|
4) |
7 |
100,000 |
250,000 |
3% – 3,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 100,000 is NOT > 300,000 that part of the condition is False but since 7 > 5 the expression is evaluated as True OR (False) With the OR operator only one of the stated conditions must be true for the entire condition to be true making the entire condition True |
|
5) |
4 |
400,000 |
350,000 |
3% – 12,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 400,000 is > 300,000 and 350,000 is > 300,000 that part of the condition is True and since 4 in NOT > 5 the expression is evaluated as False OR (True) With the OR operator only one of the stated conditions must be true for the entire condition to be true making the entire condition True |
|
6) |
3 |
100,000 |
400,000 |
2% – 2,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 100,000 is NOT > 300,000 that part of the condition is False and since 3 in NOT > 5 the expression is evaluated as False OR (False) With the OR operator at least one of the stated conditions must be true for the entire condition to be true making the entire condition False |
|
7) |
3 |
400,000 |
290,000 |
2% – 8,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 400,000 is > 300,000 But 290,000 is NOT > 300,000 that part of the condition is False and since 3 in NOT > 5 the expression is evaluated as False OR (False) With the OR operator at least one of the stated conditions must be true for the entire condition to be true making the entire condition False |
|
8) |
2 |
100,000 |
250,000 |
2% – 2,000 Because the AND conditions are enclosed in Parenthesis they are evaluated first. With the AND operator both conditions must be true for the condition to be true Since 100,000 is NOT > 300,000 And 250,000 is NOT > 300,000 that part of the condition is False and since 2 in NOT > 5 the expression is evaluated as False OR (False) With the OR operator at least one of the stated conditions must be true for the entire condition to be true making the entire condition False |
If intYearsEmployed > 4 _
Or (sngSales > 300000 And sngPreviousSales > 300000) Then
sngCommission = sngSales * .03
Else
sngCommission = sngSales * .02
End If