Você está na página 1de 3

Chapt 4 Critical Thinking

1. Grade should >= 90


2. The label displays good try
3. a) check boxes can have multiple selected, radio buttons can only have 1
selected, text boxes accept text as input
b) Check boxes for ordering a meal, radio buttons for choosing a language,
text boxes for inputting a grade.
4. a) false
b) true
c) true
d) false
e) true
5. a)If grade >= 90 Then
lblmessage.Text = "Great Job"
End If
b) if totalpoints >= 100 and totalpoints =< 200 then
lblhigh.text= High Scorer
End if
c) If Val(txtGrade.Text) > 100 Then
MessageBox.Show("Number must be less than 100.")
End If
6. a) even, odd
b) select case number mod 2
case 0
messagebox.show( Your number is even)
else
messagebox.show(your number is odd)
end select
7.
8. If chkValue1.Checked And Me.chkValue2.Checked Then
MessageBox.Show("Both applied.")
End If
.

9. If Val(Me.txtTest1.Text) >= 0 And Val(Me.txtTest1.Text) <= 100 And _


Val(Me.txtTest2.Text) >= 0 And Val(Me.txtTest2.Text) <= 100 And _
Val(Me.txtTest3.Text) >= 0 And Val(Me.txtTest3.Text) <= 100 Then
average = (Val(Me.txtTest1.Text) + Val(Me.txtTest2.Text) +
Val(Me.txtTest3.Text)) / 3 Me.lblOutput.Text = average
Else
MessageBox.Show("All three scores must be between 0 and
100.")
Me.txtTest1.Text = Nothing
Me.txtTest2.Text = Nothing
Me.txtTest3.Text = Nothing
End If
10.If Val(Me.txtNum1.Text) > Val(Me.txtNum2.Text) Then

MessageBox.Show("First number is larger")


ElseIf Val(Me.txtNum1.Text) < Val(Me.txtNum2.Text) Then
MessageBox.Show("Second number is larger")
Else
MessageBox.Show("Both numbers are equal")
End If
11.Randomize ()
Int( 46 * rnd() + 5)
12. a)
The value type should match the expression type and can be a
single value, a list separated by commas, or a range separated by
the keyword To. Is can be used with a range of values.
End Select is required to end the Select...Case statement (not End
Case).
Select Case num
Case 2, 3, Is > 10
MessageBox.Show("1st Case")
Case 20 To 29
MessageBox.Show("2nd Case")
End Select
b) If num = 2 Or num = 3 Or num > 10 Then
MessageBox.Show("1st Case")
ElseIf num >= 20 And num < 30 Then
MessageBox.Show("2nd Case")
End If
13. Select Case txtMonth.Text
Case "JANUARY", "MARCH", "MAY", "JULY", "AUGUST", "OCTOBER",
"DECEMBER"
MessageBox.Show("There are 31 days in this month.")
Case "APRIL", "JUNE", "SEPTEMBER", "NOVEMBER"
MessageBox.Show("There are 30 days in this month.")
Case "FEBRUARY"
If Val(txtYear.Text Mod 4 <> 0) Then
MessageBox.Show("There are 28 days in this month.")
ElseIf Val(txtYear.Text Mod 400 = 0) Then
MessageBox.Show("There are 29 days in this month.")
ElseIf Val(txtYear.Text Mod 100 = 0) Then
MessageBox.Show("There are 28 days in this month.")
Else
MessageBox.Show("There are 29 days in this month.")
End If
End Select
14. Private Sub btnPurchase_Click
Const TICKET_COST As Decimal = 8

Static purchase As Integer = 0


Dim tickets As Integer
Dim totalCost As Decimal
purchase += 1
If purchase = 100 Then
MessageBox.Show("Congratulations, the tickets are free!")
purchase = 0
Else
tickets = Val(Me.txtNumberTickets.Text)
totalCost = TICKET_COST * tickets
MessageBox.Show(totalCost)
End If
End Sub
15. Private Sub btnMessage_Click
Dim random As Integer
random = Int(100 * Rnd() + 1)
Select Case random
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
End Sub
16. a) T
b) F
c) T
d) F
e) F
f) F
g) F
h) F
i) F
j) T
k) T
l) F
m) F
n) T
o) F
p) F
q) F

Você também pode gostar