Imports System
Public Class MainClass
Shared Sub Main(ByVal args As String())
Dim grade As Integer = 0 ' one grade
Dim aCount As Integer = 0 ' number of As
Dim bCount As Integer = 0 ' number of Bs
Dim cCount As Integer = 0 ' number of Cs
Dim dCount As Integer = 0 ' number of Ds
Dim fCount As Integer = 0 ' number of Fs
Console.Write("Enter a grade, -1 to quit: ")
grade = Console.ReadLine()
' input and process grades
While grade <> -1
Select Case grade ' determine which grade was input
Case 100 ' student scored 100
Console.WriteLine("Perfect Score!" & vbCrLf & _
"Letter grade: A" & vbCrLf)
aCount += 1
Case 90 To 99 ' student scored 90-99
Console.WriteLine("Letter Grade: A" & vbCrLf)
aCount += 1
Case 80 To 89 ' student scored 80-89
Console.WriteLine("Letter Grade: B" & vbCrLf)
bCount += 1
Case 70 To 79 ' student scored 70-79
Console.WriteLine("Letter Grade: C" & vbCrLf)
cCount += 1
Case 60 To 69 ' student scored 60-69
Console.WriteLine("Letter Grade: D" & vbCrLf)
dCount += 1
' student scored 0 or 10-59 (10 points for attendance)
Case 0, 10 To 59
Console.WriteLine("Letter Grade: F" & vbCrLf)
fCount += 1
Case Else
' alert user that invalid grade was entered
Console.WriteLine("Invalid Input. " & _
"Please enter a valid grade." & vbCrLf)
End Select
Console.Write("Enter a grade, -1 to quit: ")
grade = Console.ReadLine()
End While
' display count of each letter grade
Console.WriteLine(vbCrLf & _
"Totals for each letter grade are: " & vbCrLf & _
"A: " & aCount & vbCrLf & "B: " & bCount _
& vbCrLf & "C: " & cCount & vbCrLf & "D: " & _
dCount & vbCrLf & "F: " & fCount)
End Sub
End Class
|