Question
The program is expected to show how many grades matched the grade entered by user, how many are higher than that grade, and how many
The program is expected to show how many grades matched the grade entered by user, how many are higher than that grade, and how many are lower than the grade. After one search is done, you program should ask if the user would like to do another search. If user enter y, then start another search. The first half is as follows..
Option Strict On
Option Explicit On
Module Module1
Sub Main()
Const SIZE_OF_CLASS As Integer = 6
Dim grades(SIZE_OF_CLASS) As Double
Dim grade As Double
Dim highestGrade As Double
Dim lowestGrade As Double
Dim sumOfGrades As Double = 0
Dim average As Double
For index = 1 To SIZE_OF_CLASS
Console.Write("Enter grade of student number " & index & ": ")
grade = Convert.ToDouble(Console.ReadLine())
While (grade 100)
Console.WriteLine("Invalid grade. Grade must be greater tha 0 and less than 100.")
Console.Write("Re-enter grade of student number " & index & ": ")
grade = Convert.ToDouble(Console.ReadLine())
End While
grades(index - 1) = grade
Next
Console.WriteLine(vbNewLine & "The grades of the class are: ")
For index = 1 To grades.GetUpperBound(0)
Console.Write(grades(index - 1) & " ")
Next
lowestGrade = grades(0)
highestGrade = grades(0)
For index = 1 To grades.GetUpperBound(0)
If grades(index - 1)
lowestGrade = grades(index - 1)
End If
If grades(index - 1) > highestGrade Then
highestGrade = grades(index - 1)
End If
sumOfGrades = sumOfGrades + grades(index - 1)
Next
average = sumOfGrades / SIZE_OF_CLASS
Console.WriteLine(vbNewLine & vbNewLine & "The average grade of the class is: " & average.ToString("0.00"))
Console.WriteLine("The highest grade of the class is: " & highestGrade.ToString("0.00"))
Console.WriteLine("The lowest grade of the class is: " & lowestGrade.ToString("0.00"))
Console.WriteLine(vbNewLine & "Press a key to exit")
Console.ReadKey()
End Sub
End Module
Please enter the grades for 6 students. Grade must be in the range of 0. 1001. Enter grade 1: 72 Grade must be in the range of 0. 1001. Enter grade 2: 69 Grade must be in the range of 0. 1001. Enter grade 2: 69 Grade must be in the range of 0. 1001. Enter grade 3: 83 Grade must be in the range of [0. 1001. Enter grade 4: 102 Grade must be in the range of [0. 1001. Enter grade 4: 92 Grade must be in the range of 0. 1001. Enter grade 5: 84 Grade must be in the range of 0. 1001. Enter grade 6: You have entered the following grades 77 69 8392 84 88 The average of the class is: 82.17 The highest grade is 92 The lowest grade is 69 Please enter the grade to search: 95 grade(s> match es> the grade you entered grade s> in the class are higher than you entered grade (s> in the class are lowerer than you entered Would you like to do another search? (y): y Please enter the grade to search: 83 grade(s> match es> the grade you entered grade s> in the class are higher than you entered grade (s> in the class are lowerer than you entered Would you like to do another search? (y/ Bye bye! nStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started