Chapter 4 Classwork_C – Ryan

advertisement
Chapter 4 Classwork #3
Please form a group of 2 or 3 students and answer the following questions.
RYAN JOHNSON - 3748
1.
What are the 3 types of selection structures?
Single-alternative selection structure
Dual-alternative selection structure
One set of tasks performed if condition is true
Called true path
Different set of tasks performed if condition is false
Called false path
If and end if
2. Write the if .. Then…Else Statement.
If condition then
Statement block to be processed when the condition is true
Else Statement block to be processed when the condition is false
End if
3. Provide one example that uses the if .. Then…Else Statement.
If intQuantity > 5 Then
dblDiscount = dbltotal * .1
dblTotal = dlbTotal – dblDiscount
End if
4. Write the 6 comparison operators.
= equal to
>Greater than
>= greater than equal to
< less than
< less than or equal to
<> not equal to
5. Define “block-level variables”
A temporary variable is used when values must be swapped
6. Define “short-circuit evaluation”
Bypasses evaluation of condition when outcome can be determined without it
Operators using technique: andAlso, orElse
7. What is the method that Visual Basic uses to convert a string to uppercase?
ToUpper method: Converts string to uppercase
8. Provide one example that converts a string to uppercase?
If strLetter.ToUpper = “P” then
9. What is the method that Visual Basic uses to convert a string to lowercase?
ToLower method: Converts string to lowercase
10. Provide one example that converts a string to lowercase?
If strLetter.ToLower = “f” Then
11. How does a TryParse method return a Boolean Value?
TryParse method returns a numeric value after converting the string, or 0 if it cannot be
converted
TryParse also returns a Boolean value indicating success or failure of the conversion
attempt
12. Provide one example that the TryParse method returns a Boolean Value.
booleanVariable = dataType.TryParse(string, numericVariableName)
Download