In: Computer Science
Create programs in Visual Basic which perform each of the following: Explain the different design choices (syntax) for option in each language Document the programs using Flowcharts Each programs source code must be included – label each with the language used
a) Nested two-way selection statements
b) Multiple-way selection statement
c) Iterative Statements – Counter controlled and Logic controlled
d) After the Counter Controlled Iterative successfully completes – Display “This was a success” on the screen.
a)
Module Module1
Sub Main()
Dim value = 200
If value < 1000 Then
If value < 500 Then
If value < 100 Then
Console.WriteLine("Value is less than 100")
Else
Console.WriteLine("Value is greater than 100")
End If
Else
Console.WriteLine("Value is greater than 500")
End If
Else
Console.WriteLine("Value is greater than 1000")
End If
Console.ReadLine()
End Sub
End Module
Output:
Value is greater than 100
b)
Module Module1
Sub Main()
Dim score As Char
score = "F"
Select Case score
Case "A"
Console.WriteLine("90-100!")
Case "B"
Console.WriteLine("80-90")
Case "C"
Console.WriteLine("70-80")
Case "D"
Console.WriteLine("60-70")
Case "F"
Console.WriteLine("50-60")
Case Else
Console.WriteLine("Invalid...")
End Select
Console.ReadLine()
End Sub
End Module
Output:
50-60
c)
Code:
Module Module1
Sub Main()
Dim value As Integer
' for loop execution
For value = 1 To 5 Step 1
Console.WriteLine("value of a: {0}", value)
Next
Console.ReadLine()
End Sub
End Module
Output
value of a: 1
value of a: 2
value of a: 3
value of a: 4
value of a: 5
d)
code:
Module Module1
Sub Main()
Dim value As Integer
' for loop execution
For value = 1 To 5 Step 1
Console.WriteLine("value of a: {0}", value)
Next
Console.WriteLine("This was success")
Console.ReadLine()
End Sub
End Module
value of a: 1
value of a: 2
value of a: 3
value of a: 4
value of a: 5
This was success
Flowcharts: