Private Sub btnEnterData_Click(sender As Object, e As EventArgs) Handles btnEnterData.Click
Dim _builder As StudentBuilder = New StudentBuilder()
For Each _student As Student In _builder.GetAllStudents
lstStudentRecord.Items.Add(_student)
Next
End Sub
End Class
Public Class Student
Public Property Name As String
Public Property Scores As Integer()
Public Function GetGrade() As String
Dim _result As String = "F"
Select Case GetAverage()
Case Is >= 90
_result = "A"
Case 80 To 89
_result = "B"
Case 70 To 79
_result = "C"
Case 60 To 69
_result = "D"
' Grade E was missing in requirements
End Select
GetGrade = _result
End Function
Private Function GetAverage() As Integer
Dim _result As Integer = 0
For Each i As Integer In Scores
_result += i
Next
Return _result / Scores.Length
End Function
Public Overrides Function ToString() As String
Return String.Format("Student Name:{0} Score:{1} Score:{2} Score:{3} Grade:{4}", _
Me.Name, Me.Scores(0), Me.Scores(1), Me.Scores(2), Me.GetGrade())
End Function
End Class
Public Class StudentBuilder
Private _students As IList(Of Student) = New List(Of Student)
Public Sub New()
Dim _numberOfStudent = CInt(InputBox("Enter total number of student?", "Number of Student"))
For i As Integer = 1 To _numberOfStudent
Dim _student As Student = New Student()
_student.Name = InputBox("Enter student name? ", "Student name")
Dim _scores(2) As Integer
For idx As Integer = 0 To _scores.Length - 1
Dim _message As String = String.Format("Enter {0} {1}'s score?", _student.Name, idx + 1)
_scores(idx) = CInt(InputBox(String.Format(_message, idx + 1), "Score?"))
Next
_student.Scores = _scores
_students.Add(_student)
Next
End Sub
Public Function GetAllStudents() As IList(Of Student)
Return Me._students
End Function
End Class
I could do it with a bit of time is there any means to contact you privatly?
Create an application that allows a teacher to enter
three test scores for each of his/her students and create a list of average scores for each student.
First of all the application should ask for total number of students. Then the application should calculate each student’s average test score and assign a letter grade based on the following grading scale 90 and above = A, 80-89 =B, 70-79=C, 60-69=D, and Below 60 = F.
Once the user clicks on Enter Data button, the application should ask for total number of students. Then ask for students name and the 3 test scores. All the data should be listed in a listbox