*成绩统计系统(5个)
* 1.录入学生成绩 int scores[]=new int [5];//0 0 0 0 0
* 2.输出学生成绩
* 3.求最高分
* 4.求最低分
* 5.求平均分
* 6.求不及格人数
* 7.求考某分的人数
* 8.退出系统
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int scores[] = new int[5];
while(true)
{
System.out.println(
" 成绩统计系统(5个)\r\n" +
" 1.录入学生成绩 int scores[]=new int [5];" +
" 2.输出学生成绩\r\n" +
" 3.求最高分\r\n" +
" 4.求最低分\r\n" +
" 5.求平均分\r\n" +
" 6.求不及格人数\r\n" +
" 7.求考某分的人数\r\n" +
" 8.退出系统\r\n");
int op = sc.nextInt();
out: switch (op) {
case 1:
{
putin(scores,sc);
break;
}
case 2:
{
putout(scores);
}
case 3:
{
max(scores);
System.out.println(max(scores));
break;
}
case 4:
{
min(scores);
System.out.println(min(scores));
break;
}
case 5:
{
double averge=averge(scores);
System.out.println(averge);
break;
}
case 6:
{
int low = low(scores);
System.out.println(low);
break;
}
case 7:
{
int people = people(scores,sc);
System.out.println(people);
break;
}
case 8:
break out;
default:
break;
}
}
}
public static void putin(int scores[], Scanner sc)
{
for(int i = 0;i <scores.length;i ++)
{
System.out.println("请输入" + (i+1) + "名学生的成绩:");
scores[i] = sc.nextInt();
}
}
public static void putout(int scores[])
{
for(int i = 0; i<scores.length;i++)
{
System.out.println("输出第" + (i+1) + "个同学成绩:" + scores[i]);
}
}
public static int max(int scores[])
{ int max=scores[0];
for(int i = 0; i<scores.length;i++)
{
if(max<scores[i])
max=scores[i];
}
return max;
}
public static int min(int scores[])
{
int min = scores[0];
for(int i = 0;i<scores.length;i++)
{
if(min>scores[i])
min = scores[i];
}
return min;
}
public static double averge(int scores[])
{
double averge=0.0;
int sum=0;
for(int i= 0;i < scores.length;i++)
{
sum = sum + scores[i];
averge = sum*1.0 /scores.length;
}
return averge;
}
public static int low(int scores[])
{
int a= 0;
for(int i=0;i<scores.length;i++)
{
if(scores[i]<60)
{
a++;
}
}
return a;
}
public static int people(int scores[],Scanner sc)
{
int people = 0;
System.out.println("输入考多少分的成绩: ");
int a = sc.nextInt();
for(int i= 0; i <scores.length;i++)
{
if(a==scores[i])
{
people++;
}
}
return people;
}
}