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
1
Expert's answer
2013-05-14T11:31:57-0400
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
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment