Вы находитесь на странице: 1из 6

Chapter4 CT

1) The Logic error is there is no equal symbol.


2) a. Good Try
b. No
c. Dim score As Integer = 25
If score >= 100 then
Me.lblMessage.Text = You Win!
ElseIf score < 50 then
Me.lblMessage.Text = Good Try.
ElseIf score < 25 then
Me.lblMessage.Text = Practice More.
End If

3) a. 1. Check Box can be selected more than one option.


2. Radio Button can only select one option at a time.
3. Text Box allows the user to put in a value.
b. 1. Check Box can be used for a check list for the morning
chores.
2. Radio Button can be used to select a pizza size.
3. Text Box can be used to enter a guess for a guessing
game.
4) a. F
b. T
c. T
d. F
e. T
5) a. If Grade >= 90 then
Me.lblMessage.Text = Great Job!
End If

b.

If total Points >= 100 And total Point <= 200 then
Me.lblHigh.Text = High Scorer

End If

c. If Val(Me.TxtGrade.Text) > 100 then


Me.lblMessage.Text = Number must be less than 100
End If

6) a. Even, Odd
b.

Select Case Mod 2


Case 0
MessageBox.Show (Your Number is Even)
Case Else
MessageBox.Show (Your Number is Odd)

End Select

7) a. No and between numTickets and <= 100, no after each


quote, Me.radstu.checked should be Me.radstudent.checked, and
should be no case.
b.

If <= 50 NumTickets And NumTickets <= 100 And_


Me.radStudent.Checked then

MessageBox.Show = (will get student and volume Discounts.)


ElseIf 50 <= NumTickets And NumTickets <= 100
MessageBox.Show = (Volume Discounts.)
ElseIf Me.RadStudent.Checked
MessageBox.Show = (Student Discounts.)
ElseIf
MessageBox.Show = (No Discounts.)
End If

8)

If Me.chkValue1.Checked And Me.chkValue2.Checked then


MessageBox.Show (Both Applied.)

End If

9)

If Val(txtTest1.Text) >= 0 And Val(txtTest1.Text) <= 100 And_

Val(txtTest2.Text) >= 0 And Val(txtTest2.Text) <= 100 And_


Val(txtTest3.Text) >= 0 And Val(txtTest3.Text) <= 100 then
Average = Val(txtTest1.Text) + Val(txtTest2.Text) + Val(txtTest3.Text) / 3
MessageBox.Show = (Average)
Else
MessageBox.Show = (Not the Average)
End If

10)

If Val(txtNum1.Text) > Val(txtNum2.Text) then


MessageBox.Show = (First Number Is Larger)

ElseIf
Val(txtNum2.Text) > Val(txtNum1.Text) then
MessageBox.Show = ( Second Number is Larger)
ElseIf
Val(txtNum1.Text) = Val(txtNum2.Text) then
MessageBox.Show = (Both are Equal)
End If

11)

Int(46 * Rnd() + 5)

12) a. No or between 2 and 3,


Select Case num
Case 2,3 Is > 10
MessageBox.Show (1st Case)
Case 20 Is <= 30
MessageBox.Show (2nd Case)
End Case

b.

If num > 10 then

MessageBox.Show (1st Case)


ElseIf num <= 20 And num < 30 then
MessageBox.Show (2nd Case)
End If

13)

Select Case Mod


Case 4, 0
MessageBox.show (28 days for February)

Case 400, 0
MessageBox.Show (29 days for February)
Case 100, 0
MessageBox.Show (28 days for February)
Case Else
MessageBox.Show (29 days for February)
End Case

14) btnPurchase_Click
Const price As Decimal = 8.00
Static Purchase As Integer
Dim TotalCost As Integer
Dim Tickets As Integer
Purchase += 1
If Purchase = 100 Then
MessageBox.Show (Congratulations the tickets are free.)
Purchase = 0
Else
Price = Val(Me.textBox1.Text)
TotalCost = Purchase * Tickets
MessageBox.Show (TotalCost.)
End If

15)

btnMessage_Click

Dim Random As Integer


Random = Int(100 * Rnd() + 1)
Select Case
Case 1, 2

2/100 = 2%

MessageBox.Show (You win $100)


Case 3 to 12

10/100 = 10%

MessageBox.Show (You win $10)


Case 13 to 62

50/100 = 50%

MessageBox.Show (You win $1)


Case Else
MessageBox.Show (Thanks for trying)
End Select

16) a. T
b. F (Decision structures are a statement that uses a condition to
determine which set of statements to executes.)
c. T
d. F (The Case Else is optional.)
e. T
f. T
g. F (Numbers generated by Rnd() are floating numbers with a
decimal portion.)
h. F (algorithm are designed before the source code.)
i. F (they are only retained by using a static declaration.)
j. T
k. T
l. F (Or is evaluated last)
m. F (it can be used on its own.)

n. T
o. F (Counter += Constant.)
p. F (multiple check boxes can be selected.)
q. F (You can use a line-continuation sequence onto the nest line.)

Вам также может понравиться