问题:
a) 创建一个名为 intMarks 的数组来存储所有 10 名学员的测试结果。
b) 提示用户将结果输入到问题 a) 中创建的数组中,
c) 计算通过测试的学员人数。假设及格分数为 50%。
d) 打印最高分和通过测试的学员人数。
“提示用户输入结果”没有问题。
但是'统计通过测试的学员人数'和'打印最高分'的输出值是错误的。
这是我的代码:
Sub Main(args As String())
Dim intMarks, intHighest, count As Integer
Dim isValid As Boolean
Dim intTra, maxTra As Integer
Dim countNum As Integer = 0
isValid = False
Do
Console.WriteLine("Enter the number of trainees: ")
maxTra = Console.ReadLine
For intTra = 1 To maxTra
Console.WriteLine("Enter the mark between 0-100: ")
intMarks = Console.ReadLine
Console.WriteLine("The mark of trainee " & intTra & " is: " & intMarks)
Next
Console.WriteLine()
If intMarks > 50 Then
countNum += 1
End If
Console.WriteLine("Have " & countNum & " trainees has passed the test by 50%.")
Console.WriteLine()
intHighest = intMarks
If intHighest > intMarks Then
intHighest = intTra
End If
Console.WriteLine("The trainee " & intTra & " has got the highest marks.")
Loop While (isValid = True)
End Sub