import java.io.*;
public class Test
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs, es, ms;
for (int i=0; i<10; i++)
{
System.out.print("请输入第" + i + "位学生的语文成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + i + "位学生的英语成绩:");
es[i] = scan.nextInt();
System.out.print("请输入第" + i + "位学生的数学成绩:");
ms[i] = scan.nextInt();
}
for (int j=0; j<10; j++)
{
int sum = cs[j] + es[j] + ms[j];
int avg = sum/3;
System.out.println("学号 中文 英语 数学 总分 平均分");
System.out.println(j + " " + cs[j] + " " + es[j] +" " + ms[j] + " " + sum + " " avg ");
}
}
}
有些细节可以自己改一下,avg 平均分可以自己改成 float 的
要是对输入排版有要求,要自己改了
更多追问追答
追问
为什么我这边不能运行????
追答
不是吧
追问
试了好几次,不能运行::>_<::>
追答
import java.util.Scanner;
public class Test
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
int[] cs = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] es = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
int[] ms = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
for (int i=0; i<10; i++)
{
System.out.print("请输入第" + (i+1) + "位学生的语文成绩:");
cs[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的英语成绩:");
es[i] = scan.nextInt();
System.out.print("请输入第" + (i+1) + "位学生的数学成绩:");
ms[i] = scan.nextInt();
}
for (int j=0; j<10; j++)
{
System.out.println("学号 中文 英语 数学 总分 平均分");
System.out.println((j+1) + " " + cs[j] + " " + es[j] +" " + ms[j] + " " + (cs[j]+es[j]+ms[j]) + " " + (cs[j]+es[j]+ms[j])/3);
}
scan.close();
}
}
不好意思,之前没有认真考虑,也没有调试,现在的可以用了
温馨提示:答案为网友推荐,仅供参考