c#编写一个学生成绩计算程序,统计出一个班学生的某门课程各分数段的人数(分数段:90分以上,80-90,70-80,

c#编写一个学生成绩计算程序,统计出一个班学生的某门课程各分数段的人数(分数段:90分以上,80-90,70-80,
编写一个学生成绩计算程序,统计出一个班学生的某门课程各分数段的人数(分数段:90分以上,80-90,70-80,60-70,60分以下)
成绩的计算方式是:平时成绩*40%+期末成绩*60%=最终成绩.
并显示出该班该门课的最高成绩和学生姓名,最低成绩和学生姓名
求教怎么修改
下面粘代码
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace xx
{
class Program
{
static void Main(string[] args)
{
int[] score = new int[10]; string[] m = { };
int i, a, b, c, d, e;
a = b = c = d = e = 0;
double[] math = new double[10];
double t = 0, max, min, r;
//int i;
Console.WriteLine("请输入20名学生的成绩 每名学生成绩输入后按回车输入下一位");
for (i = 0; i < 10; i++)
score[i] = Convert.ToInt32(Console.ReadLine());
for (i = 0; i < 10; i++)
{
switch (score[i] / 10)
{
case 10:
case 9: a++; break;
case 8: b++; break;
case 7: c++; break;
case 6: d++; break;
default: e++;
break;
}
}
for (i = 0; i < 10; i++)
math[i] = Convert.ToDouble(Console.ReadLine());
max = math[0];
min = math[0];
for (i = 0; i < 10; i++)
{
t += math[i];
if (math[i] > max) max = math[i];
if (math[i] < min) min = math[i];
}
r = t / 10;
Console.WriteLine("平均分为:{0}", r);
Console.WriteLine("最高分为:{0}", max);
Console.WriteLine("最低分为:{0}", min);
Console.WriteLine("得优人数 :{0}", a);
Console.WriteLine("得良人数 : {0}", b);
Console.WriteLine("得好人数 :{0}", c);
Console.WriteLine("及格人数 :{0}", d);
Console.WriteLine("不及格人数 :{0}", e);
Console.ReadLine();

}
}
}
我没在意过 1年前 已收到1个回答 举报

sky300 幼苗

共回答了11个问题采纳率:100% 举报

int[] score = new int[10]; string[] m = { };
int i, a, b, c, d, e;
a = b = c = d = e = 0;
double t = 0, max, min, r;
Console.WriteLine("请输入20名学生的成绩 以回车符区分");
for (i = 0; i < 10; i++)
{
int inputScore = 0;
if (!int.TryParse(Console.ReadLine(), out inputScore))
{
Console.WriteLine("请输入数字类型成绩");
i--;
}
score[i] = inputScore;
}
for (i = 0; i < 10; i++)
{
switch (score[i] / 10)
{
case 10:
case 9: a++; break;
case 8: b++; break;
case 7: c++; break;
case 6: d++; break;
default: e++;
break;
}
}
max = score[0];
min = score[0];
for (i = 0; i < 10; i++)
{
t += score[i];
if (score[i] > max) max = score[i];
if (score[i] < min) min = score[i];
}
r = t / 10;
Console.WriteLine("平均分为:{0}", r);
Console.WriteLine("最高分为:{0}", max);
Console.WriteLine("最低分为:{0}", min);
Console.WriteLine("得优人数 :{0}", a);
Console.WriteLine("得良人数 : {0}", b);
Console.WriteLine("得好人数 :{0}", c);
Console.WriteLine("及格人数 :{0}", d);
Console.WriteLine("不及格人数 :{0}", e);
Console.ReadLine();

1年前

6
可能相似的问题
Copyright © 2024 YULUCN.COM - 雨露学习互助 - 16 q. 0.013 s. - webmaster@yulucn.com