
Vb程序编写题
设某班共10名学生,为了评定某门课程的奖学金,按照规定超过全班平均成绩10%者发给一等奖,超过全班成绩5%者发给二等奖。试编写程序,输出应获奖学金的学生名单(包括姓名、学...
设某班共10名学生,为了评定某门课程的奖学金,按照规定超过全班平均成绩10%者发给一等奖,超过全班成绩5%者发给二等奖。试编写程序,输出应获奖学金的学生名单(包括姓名、学号、成绩、奖学金等级)。
展开
1个回答
展开全部
Private Type Student
Name as String
ID as Short
Score as Single
End Type
'把以下代码放在事件中,如按钮的点击事件中
Dim Students(10) as Student
Dim Total as Single
Dim Average as single
Dim i as long
With Students(1)
.Name = "张三"
.ID = 1
.Score = 97
End with
.
. '用同样的方法初始化Students(2 - 10)
.
Total = 0
For i = 1 to 10
Total = Total + Students(i).Score
next i
Average = Total/10
For i = 1 to 10
If (Students(i) - Average)/Average >= 0.1 then
Print Students(i).Name,Students(i).ID,Students(i).Scrore,"一等"
elseif (Students(i) - Average)/Average >= 0.05 then
Print Students(i).Name,Students(i).ID,Students(i).Scrore,"二等"
End If
Next i
Name as String
ID as Short
Score as Single
End Type
'把以下代码放在事件中,如按钮的点击事件中
Dim Students(10) as Student
Dim Total as Single
Dim Average as single
Dim i as long
With Students(1)
.Name = "张三"
.ID = 1
.Score = 97
End with
.
. '用同样的方法初始化Students(2 - 10)
.
Total = 0
For i = 1 to 10
Total = Total + Students(i).Score
next i
Average = Total/10
For i = 1 to 10
If (Students(i) - Average)/Average >= 0.1 then
Print Students(i).Name,Students(i).ID,Students(i).Scrore,"一等"
elseif (Students(i) - Average)/Average >= 0.05 then
Print Students(i).Name,Students(i).ID,Students(i).Scrore,"二等"
End If
Next i
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询