Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Student Test Scores A teacher has six students and wants you to create an applic

ID: 3529976 • Letter: S

Question

Student Test Scores

A teacher has six students and wants you to create an application that stores their grade data in a file and prints a grade report. The application should have a structure that stores the following student data: Name (a string), Test Scores (an array of five Doubles), and Average (a Double). Because the teacher has six students, the application should use an array of six structure variables.


The application should allow the user to enter data for each student, and calculate the average test score.



The user should be abled to save the data to a file, read the data from the file, and print a report showing each student's test scores and average score. The form shows a meny system. You may you buttons instead if you prefer.


Input validation: Do not accept test scores less that zero or greater than 100.

Explanation / Answer

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCalcData.Click ' This procedure gets the tests socres, then calculates and ' displays the average score and letter grade. Dim sngTotal As Single ' Holds the running total of test scores Dim intNumScores As Integer ' The number of test scores Dim sngAverage As Single ' Average of test scores Dim strNames As String ' Students names Dim strInput As String ' To hold user input Dim intCount As Integer ' Counter Variable for the loop ' Get the number of students. strInput = InputBox("How many students test scores do you want " & _ "to average?", "Enter a Value") If Not Integer.TryParse(strInput, intNumScores) Then Return End If ' Store the starting values in total and count. sngTotal = 0 intCount = 1 ' Get the test scores. Do Until intCount > intNumScores strInput = InputBox("Enter the value for test score " _ & intCount.ToString, "Test Score Needed") sngTotal += CSng(strInput) intCount += 1 Loop ' Calculate and display the average. If intNumScores > 0 Then sngAverage = sngTotal / intNumScores Else sngAverage = 0.0 End If lstGradeReport.Text = sngAverage.ToString 'Calculate and display the letter grade. If sngAverage < 60 Then lstGradeReport.Text = "F" ElseIf sngAverage < 70 Then lstGradeReport.Text = "D" ElseIf sngAverage < 80 Then lstGradeReport.Text = "C" ElseIf sngAverage < 90 Then lstGradeReport.Text = "B" ElseIf sngAverage <= 100 Then lstGradeReport.Text = "A" End If End Sub