有3个学生,每个学生4门课。
先求每个学生的平均成绩,然后展示高于平均成绩的分数。
Public Class Form1Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.ClickDim pj%, i%, n%, sum%, say$Dim cj(0 To 3) As Integeri = 1say = ""Dosum = 0For n = 1 To 4cj(n - 1) = Val(InputBox("请输入第" & i & "个学生第" & n & "门课成绩:", "各门课成绩"))sum = sum + cj(n - 1)say = say & cj(n - 1) & " "Nextpj = sum / 4say = say & "高于平均的分数:"For n = 0 To 3If cj(n) > pj Thensay = say & cj(n) & " "End IfNextSelect Case pjCase 0 To 59say = say & "平均成绩小于60,不能评定奖学金!" & Chr(13)Case 60 To 69say = say & "平均成绩为" & pj & ",可以评定四等奖学金!" & Chr(13)Case 70 To 79say = say & "平均成绩为" & pj & ",可以评定三等奖学金!" & Chr(13)Case 80 To 89say = say & "平均成绩为" & pj & ",可以评定二等奖学金!" & Chr(13)Case 90 To 100say = say & "平均成绩为" & pj & ",可以评定一等奖学金!" & Chr(13)End SelectLabel1.Text = sayi = i + 1If i = 4 ThenExit DoEnd IfLoopEnd Sub
End Class