1. Please use a single example that uses the If ---Then---Else statement to code single-alternative and dual-alternative selection structures.
2. SELECT CASE (include case else statement) vs. IF....ELSE..block, give an example of how to use each structure
Please keep it as simple as possible!
1.
a. Single alternative Example
if (power is on) Then
Switch on the Light;
b. Dual alternative Example
If--- Then---Else statement is used, based on only if there is only two possible case.
Example : If (age >= 18) Then You can vote;
Else You can't vote.
2. SELECT CASE is used based on given character or Integeral value only.
Example: Consider integer input as day number. Then, we can write SELECT CASE as day as shown below:
Dim number As Integer = 4
Select Case number
Case 1 to 7 PRINT "Weekday"
Case ELSE PRINT "Invalid Input"
End Select
For this: output would be Weekday
Use of if-Else and Select Case:
I. If input type is always same then use select case.
II. If condition is very different and not fixed by the value, use if-else
Get Answers For Free
Most questions answered within 1 hours.