' Visual Basic 2008 9.0 .NET Examples - Array Datatype and Jagged Arrays - Arrays : Module ExerciseSolution Sub Main() Console.Write("Student Count ? ") Dim studentCount As Integer = Console.ReadLine() Console.Write("Topic Count ? ") Dim topicCount As Integer = Console.ReadLine() Console.WriteLine() ' Dim studentUpperbound As Integer = studentCount - 1 Dim names(studentUpperbound) As String Dim topicUpperbound As Integer = topicCount Dim scores(studentUpperbound, topicUpperbound) As Double Dim students(1) As Array Const namesIndex As Integer = 0, scoresIndex As Integer = 1 students(namesIndex) = names students(scoresIndex) = scores ' Dim studentIndex, topicIndex As Integer For studentIndex = 0 To studentUpperbound Console.Write("Name Student " & (studentIndex + 1) & " ? ") students(namesIndex)(studentIndex) = Console.ReadLine() For topicIndex = 0 To topicUpperbound - 1 Console.Write(students(namesIndex)(studentIndex) & _ " Score Topic " & (topicIndex + 1) & " ? ") students(scoresIndex)(studentIndex, topicIndex) = _ Console.ReadLine() Next Console.WriteLine() Next ' For studentIndex = 0 To studentUpperbound For topicIndex = 0 To topicUpperbound - 1 students(scoresIndex)(studentIndex, topicUpperbound) += _ students(scoresIndex)(studentIndex, topicIndex) Next students(scoresIndex)(studentIndex, topicUpperbound) /= _ topicUpperbound Next ' Console.WriteLine() For studentIndex = 0 To studentUpperbound Console.WriteLine("Name : " & students(namesIndex)(studentIndex)) For topicIndex = 0 To topicUpperbound - 1 Console.WriteLine("Score Topic " & (topicIndex + 1) & " : " & _ students(scoresIndex)(studentIndex, topicIndex)) Next Console.WriteLine("Average Score : " & _ students(scoresIndex)(studentIndex, topicUpperbound)) Console.WriteLine() Next ' Console.ReadLine() End Sub End Module ' Visit www.studyvb.com for more examples. Copyright 2003-2008 De Wolf.