In Visual Basic, the Select Case structure performs one of many actions (or sequences of actions), depending on the value of an expression.
(a) Write a program using Select...case block that prompts a user for an exam score. The grade to be dispayed is based on the Table 1 below.
Table 1: Exam Score
Score
Grade
90-100
A
80-89
B
70-79
C
60-69
D
0-59
F
Module Module1
Sub Main()
Dim examScore As Integer
Console.Write("Enter exam score: ")
Integer.TryParse(Console.ReadLine(), examScore)
Dim grade As String = "Wrong exam score"
Select Case examScore
Case 90 To 100
grade = "A"
Case 80 To 89
grade = "B"
Case 70 To 79
grade = "C"
Case 60 To 69
grade = "D"
Case 0 To 59
grade = "F"
End Select
Console.WriteLine("Your grade is: {0}", grade)
Console.ReadLine()
End Sub
End Module
Comments
Leave a comment