Dim studentID(0) As String
Dim engMark(0), matMark(0), sciMark(0) As Integer
Dim engStats(2), matStats(2), scieStats(2) As Integer
Const firstEntryMsg As String = "Student data is entered in this format (CSV):ID,Result_English,Result_Maths,Result_Science "
Console.WriteLine("Please choose from the menu: {0}, {1}, {2}, {3}", "INPUT", "DISPLAY", "SEARCH", "EXIT")
menuOption = Console.ReadLine()
Select Case menuOption.Toupper()
Console.WriteLine("What do you want to do next?")
Console.WriteLine("What do you want to do next?")
Console.WriteLine("There is no student record! You need to input student results first!")
Console.WriteLine("What do you want to do next?")
Console.WriteLine("There is no student record! You need to input student results first!")
Console.WriteLine("You are exiting the program")
Console.WriteLine("Not a valid option. Try again!")
Public Sub InputIDAndMarks()
Dim entryCorrect As Boolean = True
Console.WriteLine("Enter the number of students in your class: ")
NumStud = Console.ReadLine()
ReDim studentID(NumStud - 1), engMark(NumStud - 1), matMark(NumStud - 1), sciMark(NumStud - 1)
Console.WriteLine("Enter student {0} tests:", i + 1)
stdInfor = Input(firstEntryMsg).Split(",")
If stdInfor.Length <> 4 Then
Console.WriteLine("You need to enter 4 items sperated by comma!")
ElseIf stdInfor(0).Length <> 5 Then
Console.WriteLine("ID needs to be 5 digit string! ")
ElseIf Array.IndexOf(studentID, stdInfor(0)) <> -1 Then
Console.WriteLine("This studentID already exists")
ElseIf stdInfor(1) < 0 Or stdInfor(1) > 100 Then
Console.WriteLine("The english score needs to be between 0 and 100!")
ElseIf stdInfor(2) < 0 Or stdInfor(2) > 100 Then
Console.WriteLine("The maths score needs to be between 0 and 100!")
ElseIf stdInfor(3) < 0 Or stdInfor(3) > 100 Then
Console.WriteLine("The science score needs to be between 0 and 100!")
If entryCorrect = False Then
stdInfor = Input(firstEntryMsg).Split(",")
Loop Until entryCorrect = True
studentID(i) = stdInfor(0)
engMark(i) = IsMarkLess20(stdInfor(1))
matMark(i) = IsMarkLess20(stdInfor(2))
sciMark(i) = IsMarkLess20(stdInfor(3))
Public Function Input(sMesage As String) As String
Console.WriteLine(sMesage)
Public Function IsMarkLess20(mark As Integer)
AvgMaxMin(engMark, engStats)
AvgMaxMin(matMark, matStats)
AvgMaxMin(sciMark, scieStats)
Public Sub AvgMaxMin(mark() As Integer, stats() As Integer)
Dim totoal, avg As Integer
ElseIf mark(i) < min Then
totoal = totoal + mark(i)
Public Sub DisplayResults()
Console.WriteLine("{0,-8}{1,-8}{2,-8}{3,-8} ", "ID", "English", "Maths", "Science")
Console.WriteLine("{0,-8}{1,-8}{2,-8}{3,-8} ", studentID(i), engMark(i), matMark(i), sciMark(i))
Public Sub DisplayStats()
Dim statsDescrib() As String = {"AVERGAE", "MAX", "MIN"}
Console.WriteLine("{0,-8}{1,-8}{2,-8}{3,-8} ", statsDescrib(i), engStats(i), matStats(i), scieStats(i))
Dim searchID As String = ""
Dim overalAvg As Integer = 0
Console.WriteLine("Enter the student ID you are searching for:")
searchID = Console.ReadLine()
index = Array.IndexOf(studentID, searchID)
Console.WriteLine("The ID you entered does not exist! ")
overalAvg = (engMark(index) + matMark(index) + sciMark(index)) / 3
Console.WriteLine("{0,-8}{1,-8}{2,-8}{3,-8} ", "ID", "English", "Maths", "Science")
Console.WriteLine("{0,-8}{1,-8}{2,-8}{3,-8} ", studentID(index), engMark(index), matMark(index), sciMark(index))
Console.WriteLine("Student {0} overall average result is: {1}", studentID(index), overalAvg)