Cant tell what im doing wrong no matter what numbers i enter it always return as a F and I cant get the average to calculate correctly plz help i uploaded the file also
Below is the assignment
Create an application that allows a teacher to enter three test scores each of the three students. The application should calculate each student’s average score and assign a letter grade based on the following grading scale:
Average Test Score Letter Grade
90 or greater A
80 through 89 B
70 through 79 C
60 through 69 D
Below 60 F
The application should prompt the user for each students name and three test scores. A box needs to appear after all the data has been entered showing the results.
Public Class Form1
Private Sub btnEnter_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnEnter.Click
' Assigning variable as a string for student name
Dim studentName As String
Dim strScore As String
Dim result As String
' Assigning Test Scores as a Decimal
Dim numScore As Decimal
' Assnumigning average as a decimal
Dim average As Decimal
' Assigning counter for repeatable names
Dim counter As Integer = 1
' Assigning counter for Test scores
Dim scoreCounter As Integer = 1
For counter = 1 To 3
' Prompting user to enter names
studentName = InputBox("Enter Student name" & counter, "Students name")
numScore = scoreCounter + scoreCounter + scoreCounter
' Asking for the three given socres
For scoreCounter = 1 To 3
' Prompting user to enter students test scores.
strScore = InputBox("Enter Score " & scoreCounter, "Students Score", " ")
If strScore = "" Then
' Canceling the operation.
MsgBox("You have cancelled the grading process")
Exit Sub
End If
If Not IsNumeric(strScore) Then
scoreCounter -= 1
' Making sure the scores are numeric to prevent any errors.
MsgBox("Score has to be numeric..." & vbCrLf & "Click ok and enter score again")
Else
End If
Next
average = numScore / 3
' Giving the end result and averages for the 3 students
result &= studentName & "'s Average Grade is:" & calcGrade(average) & vbCrLf
Next
MsgBox(result, MsgBoxStyle.OkOnly, "Results")
End Sub
Private Function calcGrade(ByVal avg As Decimal) As String
' Assigning Grade values for the test scores
If avg >= 90 Then
Return "A"
ElseIf avg >= 80 Then
Return "B"
ElseIf avg >= 70 Then
Return "C"
ElseIf avg >= 60 Then
Return "D"
ElseIf avg < 59 Then
Return "F"
End If
End Function
End Class