In: Computer Science
Using If-Else conditional statement write a Visual Basic Program to display:
(i) “STOP” if the user enters “R”
(ii) “CAUTION” if the user enters “Y”
(iii) “GO” if the user enters “G”
(iv) “Invalid” if the user enters any other character
Module VBModule
Sub Main()
'variable declartion
Dim ch As String
'get user input
Console.Write("Enter a character: ")
ch = Console.ReadLine()
'check if input is "R"
If ch = "R" Then
Console.WriteLine("STOP")
'check if input is "Y"
elseif ch = "Y" Then
Console.WriteLine("CAUTION")
'check if input is "G"
elseif ch = "G" Then
Console.WriteLine("GO")
else
Console.WriteLine("Invalid")
End If
End Sub
End Module
The screenshot of the above source code is given below:
OUTPUT:
Enter a character: Y
CAUTION