import java
.util
.Scanner
;
public class Demo07 {
public static void main(String
[] args
) {
Scanner scanner
=new Scanner(System
.in);
System
.out
.println("请输入本版学生总数");
int studentcout
=scanner
.nextInt();
int achivement
[][]=new int[studentcout
][4];
for(int i
=0;i
<studentcout
;i
++) {
System
.out
.println("请输入第"+(i
+1)+"个学生的编号");
achivement
[i
][0]=scanner
.nextInt();
System
.out
.println("请输入语文成绩:");
achivement
[i
][1]=scanner
.nextInt();
System
.out
.println("请输入数学成绩:");
achivement
[i
][2]=scanner
.nextInt();
System
.out
.println("请输入英语成绩:");
achivement
[i
][3]=scanner
.nextInt();
}
System
.out
.println("学生成绩结果如下");
System
.out
.println("--------------------");
System
.out
.print("学生编号\t语文成绩"
+ "\t数学成绩\t"+ "英语成绩\t平均成绩\t总成绩");
for(int i
=0;i
<achivement
.length
;i
++) {
double sum
=0;
double ave
=0;
for(int j
=0;j
<achivement
[i
].length
;j
++) {
System
.out
.print(achivement
[i
][j
]+"\t");
if(j
>0) {
sum
+=achivement
[i
][j
];
}
}
ave
=sum
/3;
System
.out
.print(String
.format("%.2f", ave
)+
"\t"+(int
)sum
+"\n");
}
}
}
浏览效果
转载请注明原文地址:https://ipadbbs.8miu.com/read-1110.html