Use the code shown in Figure 528 to answer Review Questions
Use the code shown in Figure 5-28 to answer Review Questions 1 through 4.
If dblSales <= 0 Then
dblRate = 0
ElseIf dblSales < 460 Then
dblRate = 0.05
ElseIf dblSales < 1000 Then
dblRate = 0.1
Else
dblRate = 0.15
End If
1. What will the code in Figure 5-28 assign to the dblRate variable when the dblSales
variable
contains the number 459.99?
a. 0
b. 0.05
c. 0.1
d. 0.15
2. What will the code in Figure 5-28 assign to the dblRate variable when the dblSales
variable contains the number 0?
a. 0
b. 0.05
c. 0.1
d. 0.15
3. What will the code in Figure 5-28 assign to the dblRate variable when the dblSales
variable contains the number 999.75?
a. 0
b. 0.05
c. 0.1
d. 0.15
4. What will the code in Figure 5-28 assign to the dblRate variable when the dblSales
variable contains the number 1000?
a. 0
b. 0.05
c. 0.1
d. 0.15
Use the code shown in Figure 5-29 to answer Review Questions 5 through 8.
If strLevel = \"1\" OrElse strLevel = \"2\" Then
lblStatus.Text = \"Bronze\"
ElseIf strLevel = \"3\" OrElse strLevel = \"4\" Then
lblStatus.Text = \"Silver\"
ElseIf strLevel = \"5\" Then
lblStatus.Text = \"Gold\"
Else
lblStatus.Text = \"Platinum\"
End If
5. What will the code in Figure 5-29 assign to the lblStatus control when the strLevel
variable
contains the string “2”?
a. Bronze
b. Gold
c. Platinum
d. Silver
6. What will the code in Figure 5-29 assign to the lblStatus control when the strLevel
variable
contains the string “5”?
a. Bronze
b. Gold
c. Platinum
d. Silver
7. What will the code in Figure 5-29 assign to the lblStatus control when the strLevel
variable contains the string “10”?
a. Bronze
b. Gold
c. Platinum
d. Silver
8. What will the code in Figure 5-29 assign to the lblStatus control when the strLevel
variable
contains the string “3”?
a. Bronze
b. Gold
c. Platinum
d. Silver
9. A nested selection structure can appear _____________________.
a. only in an outer selection structure’s
false path
b. only in an outer selection structure’s
true path
c. in either an outer selection structure’s
true path or its false path
10. Which of the following Case clauses is valid in a Select Case statement whose
selectorExpression
is an Integer variable named intCode?
a. Case Is > 7
b. Case 3, 5
c. Case 1 To 4
d. all of the above
Use the code shown in Figure 5-30 to answer Review Questions 11 through 14.
11. What will the code in Figure 5-30 assign to the strStatus variable when the
intLevel
variable contains the number 4?
a. Bronze
b. Gold
c. Platinum
d. Silver
12. What will the code in Figure 5-30 assign to the strStatus variable when the
intLevel
variable contains the number 8?
a. Bronze
b. Gold
c. Platinum
d. Silver
13. What will the code in Figure 5-30 assign to the strStatus variable when the
intLevel
variable contains the number 7?
a. Bronze
b. Gold
c. Platinum
d. Silver
14. What will the code in Figure 5-30 assign to the strStatus variable when the
intLevel
variable contains the number 1?
a. Bronze
b. Gold
c. Platinum
d. Silver
15. List the four errors commonly made when writing selection structures. Which errors
produce the correct results but in a less efficient way?
16. Explain the meaning of the term desk-checking.
Solution
1 b. 0.05
2. a. 0
3. c. 0.1
4 d. 0.15
5. a. Bronze
6. b. Gold
7 .c. Platinum
8. d. Silver
9. c. in either an outer selection structure’s
true path or its false path
10 d. all of the above
Fig 5:30 is not given so using 5.29 for following questions
11.d. Silver
12.c. Platinum
13. c. Platinum
14. a. Bronze
15. Four errors commonly made when writing selection structures
16. desk-checking is the method of manually checking the logic and code of program.


