Name: ___________________ four You may cross out the answer to avoid grading.

advertisement
Name: ___________________
Quiz Two
Choose four questions to answer. Only first four answers will be graded.
You may cross out the answer to avoid grading.
1. What is the difference between logic and syntax errors? Explain.
2. What are functions? How many values do they return? Explain.
3. Write a code that declares a variable that will hold a gasoline price per gallon. Give an appropriate name
and data type. Briefly, explain your choices.
4. Demonstrate each step of calculation of the following code. You need to show how each arithmetic
operator works. Show the final value of decTotalPay:
sngHourlyRate = 10
intHoursWorked = 20
decBonus = 60
decTotalPay = intHoursWorked * sngHourlyRate + ( decBonus / ( intHoursWorked + 10 ) )
Name: ___________________
Quiz Two
5. Assume that txtAge is a TextBox control and that the user has entered the value 21 into the TextBox.
Determine the action performed by the following code:
Dim intAge As Integer
intAge = Val(txtAge.Text)
If intAge < 0 Then
txtAge.Text = "Enter a value greater than or equal to zero."
ElseIf intAge > 13 Then
txtAge.Text = "Child"
ElseIf intAge > 20 Then
txtAge.Text = "Teenager"
ElseIf intAge >= 21 Then
txtAge.Text = "You can vote!"
ElseIf intAge = 21 Then
txtAge.Text = "Young Adult"
Else
txtAge.Text = "Grownup"
End If
6. Assume that txtAge is a TextBox control and that the user has entered the value 21 into the TextBox. Also,
assume that chkStudent is a CheckBox control and that the user has put a check mark into the CheckBox.
Determine the action performed by the following code:
Dim intAge As Integer = Val(txtAge.Text)
Dim blnStudent As Boolean = chkStudent.Checked
If intAge < 0 Then
txtAge.Text = "Enter a value greater than or equal to
zero."
ElseIf (intAge <= 13) AndAlso Not blnStudent Then
txtAge.Text = "Child"
ElseIf intAge < 20 AndAlso blnStudent Then
txtAge.Text = "Teenager"
ElseIf intAge = 21 OrElse Not (Not blnStudent) Then
txtAge.Text = "You can vote!"
ElseIf intAge > 21 Xor blnStudent Then
txtAge.Text = "Young Adult"
Else
txtAge.Text = "Grownup"
End If
Download