write a VB program that reads 50 grades (each grade should be between 0 and 100), and then produces the frequency of each grade. The result should be stored in an array. You should not use any type of IF statements or SELECT CASE statement.
Example: Suppose the input grades are 1,4,3,4,1,4,2 … The output should be as follows:
grade frequency
0 0
1 2
2 1
3 1
4 3
...
100 0
Module Module1
Private arrayofGrades(50) As Integer 'decalre variable arrayofGrades
Private arrayofGradescounts(50) As Integer 'decalre variable
arrayofGradescounts
Sub Main()
For i As Integer = 0 To 49
Console.Write("Enter grade: ") 'input grades
arrayofGrades(i) = Integer.Parse(Console.ReadLine()) 'read grade
Next
'calculate the frequency of each grade
For i As Integer = 0 To 99
arrayofGradescounts(arrayofGrades(i)) += 1
Next
'show result
For i As Integer = 0 To 99
Console.Write((i + 1).ToString() + " " +
arrayofGradescounts(arrayofGrades(i)).ToString())
Next
'delay
Console.ReadLine()
End Sub
End Module
Need a fast expert's response?
Submit order
and get a quick answer at the best price
for any assignment or question with DETAILED EXPLANATIONS!