i need to create a project that allows a teacher to enter three test scores for each of the three students.
the appliaction should calculate each students average test score and assign a letter grade based on the grading scale shown below.

average test score letter grade
90 or greater a
80 through 89 b
70 through 79 c
60 through 69 d
below 60 f

input boxes should be used for the following user input. the application should prompt the user for each students name and three scores.

Input Validation: Should be used on the test scores to assure they are valid. a negative number or character should not be accepted. only postive whole numbers less than or equal to 100 should be accepted.

Public Class frmGradeReport
    Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
        Me.Close()
    End Sub
    Private Sub btnEnterData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnENterData.Click
        Dim Name As String
        Dim Score1 As Integer
        Dim Score2 As Integer
        Dim Score3 As Integer
        Dim Average As String
        Dim intcount As String
        Dim Test As Single



        Test = 3
        intcount = 0

        Do Until intcount = Test
            Name = InputBox("Enter student's name:", "Input Needed")
            Score1 = InputBox("Enter a test Score1:", "Input Needed")
            Score2 = InputBox("Enter a test Score2:", "Input Needed")
            Score3 = InputBox("Enter a test Score3:", "Input Needed")

            Average = (Score1 + Score2 + Score3) / 3

            If Average < 60 Then
                lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "E")
            ElseIf Average < 70 Then
                lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "D")
            ElseIf Average < 80 Then
                lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "C")
            ElseIf Average < 90 Then
                lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "B")
            ElseIf Average < 100 Then
                lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "A")
            End If

            intcount += 1
        Loop
    End Sub
End Class

any help would be appreciated thank you

Recommended Answers

All 3 Replies

Do you have a specific question?

What is your question exactly?

There is no distinct question.

Input Validation: Should be used on the test scores to assure they are valid. a negative number or character should not be accepted. only postive whole numbers less than or equal to 100 should be accepted.

From the above lines, it can be assumed that the question is "How could it check and validate the InputBox Return values?".
From my point of view, If I am right, it is a good question that how can you restrict, check the desired condition and also validate.

Your codes are quite right, but some modification is needed.
The inputbox for name is right.
But for scores, use of three inputboxs is too much straight forward. And if you try to check the validation for every inputbox you should get a lengthy codes and everytime check the invalid value and prompt to the user to re-enter the value is most boring work.
I have done some modification of your codes. It can help you to check the values of an InputBox Return value.

Public Class frmGradeReport
    Private Sub BtnExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnExit.Click
        Me.Close()
    End Sub
    Private Sub btnEnterData_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnENterData.Click
        Dim Name As String = ""
        Dim score As Integer = 0
        Dim Score1 As Integer = 0
        Dim Score2 As Integer = 0
        Dim Score3 As Integer = 0
        Dim Average As String = 0
        Dim intcount As Integer = 0
        Dim Test As Integer = 0



        Do Until Test = 3
            intcount = 0

            ' Get Student name
            Name = StudentName()

            Do Until intcount = 3

                'Get and store obtained numbers
                If Score1 <= 0 Then
                    Score1 = ScoreInput(Name, intcount)
                ElseIf Score2 <= 0 Then
                    Score2 = ScoreInput(Name, intcount)
                Else
                    Score3 = ScoreInput(Name, intcount)
                End If
                intcount += 1
            Loop

            Average = (Score1 + Score2 + Score3) / 3

            'Check average conditions to display
            Select Case Average
                Case 91 To 100 : lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "A")
                Case 81 To 90 : lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "B")
                Case 71 To 80 : lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "C")
                Case 61 To 70 : lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "D")
                Case Else : lstDisplay.Items.Add(Name + " " + "Average:" + Average.ToString() + " " + "Grade:" + " " + "E")
            End Select

            Score1 = 0
            Score2 = 0
            Score3 = 0

            Test += 1
        Loop
    End Sub

    Private Function StudentName() As String
        Dim Result As String = InputBox("Enter student's name:", "Input Needed")

        If String.IsNullOrWhiteSpace(Result) Then
            StudentName()
        End If

        Return Result
    End Function

    Private Function ScoreInput(ByVal name As String, ByVal icount As Integer) As Integer
        Dim x As String = "Student name : " & name & vbCrLf & "Enter Score for Subject" & icount + 1

        Dim Result As String = InputBox(x, "Input Needed")

        'Check validation
        If Not IsNumeric(Result) Then
            ScoreInput(name, icount)
        End If

        'Check the range of score is between 0 and 100
        If (Val(Result) < 0) Or (Val(Result) > 100) Then
            ScoreInput(name, icount)
        End If

        'Return the obtained number
        Return Val(Result)
    End Function
End Class
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.