Hey all.
I am making an application through 10 exam scores (integers 0-100) are entered into separate text boxes within a group box, and are analyzed with the click of a button. The list box should then display the mean, standard deviation, and the list of scores and corresponding grades. According to the bell-curve, the letter grades are determined as follows:
ES >= m + 1.5s = A
m + 0.5s <= ES < m + 1.5s = B
m – 0.5s <= ES < m + 0.5s = C
m – 1.5s <= ES <= m – 0.5s = D
ES < m – 1.5s = F
Here is the code I have so far:
Public Class Form1
Private Sub btnAnalyze_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAnalyze.Click
Dim Score(9), ES As Integer
Dim stdDeviation, mean As Double
Dim Grade(9) As String
Dim fmtstr As String = "{0, -15} {1, 15}"
'Store scores into array
Score(0) = TextBox1.Text
Score(1) = TextBox2.Text
Score(2) = TextBox3.Text
Score(3) = TextBox4.Text
Score(4) = TextBox5.Text
Score(5) = TextBox6.Text
Score(6) = TextBox7.Text
Score(7) = TextBox8.Text
Score(8) = TextBox9.Text
Score(9) = TextBox10.Text
'Determine the mean
mean = (Score(0) + Score(1) + Score(2) + Score(3) + Score(4) + Score(5) + Score(6) + Score(7) _
+ Score(8) + Score(9)) / 10
'Determine the standard deviation
stdDeviation = System.Math.Sqrt((((Score(0) - mean) ^ 2) + ((Score(1) - mean) ^ 2) + ((Score(2) - mean) ^ 2) + ((Score(3) - mean) ^ 2) + ((Score(4) - mean) ^ 2) + _
(Score(5) - mean) ^ 2 + ((Score(6) - mean) ^ 2) + ((Score(7) - mean) ^ 2) + ((Score(8) - mean) ^ 2) + ((Score(9) - mean) ^ 2)))/10))
'Determine the letter grades and store them into an array
For i = 0 To 9
Score(i) = ES
If ES >= mean + (1.5 * stdDeviation) Then
Grade(i) = "A"
ElseIf mean + (0.5 * stdDeviation) <= ES < mean + (1.5 * stdDeviation) Then
Grade(i) = "B"
ElseIf mean - (0.5 * stdDeviation) <= ES < mean + (0.5 * stdDeviation) Then
Grade(i) = "C"
ElseIf mean - (1.5 * stdDeviation) <= ES <= mean - (0.5 * stdDeviation) Then
Grade(i) = "D"
ElseIf ES < mean - (1.5 * stdDeviation) Then
Grade(i) = "F"
End If
Next
'Display analysis of grades
Display.Items.Add(Str("There were 10 exams."))
Display.Items.Add(Str("Mean:" & CStr(mean)))
Display.Items.Add(Str("Standard Deviation:" & CStr(stdDeviation)))
For i = 0 To 9
Display.Items.Add(String.Format(fmtstr, CStr(Score(i)), Grade(i)))
Next
End Sub
End Class
The syntax error is on line 27 at the end of the stdDeviation equation. It reads "end of statement expected", and I have no clue what to do about it. What is the problem, and how can I resolve it? Also, is there any way I could have structured the program so that it accomplishes this task more efficiently. I am new to programming, and I would really appreciate any help I can get.