/*/**Tochangethistemplate,chooseTools|Templates*andopenthetemplateintheeditor.*/packagep1;/****@authorA524*/importjava.util.Scanner;publicclassstu{publicstaticvoidmain(St...
/*
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package p1;
/**
*
* @author A524
*/
import java.util.Scanner;
public class stu {
public static void main(String args[]) {
String[] stu_score_name = {"学号", "课程1", "课程2", "课程3", "总分", "平均分"};
int[][] stu_score = new int[5][6];
Scanner sc = new Scanner(System.in);
int sel = 0;
while (1 == 1) {
do {
System.out.println(" 欢迎使用学生成绩管理系统V1.0");
System.out.println();
System.out.println(" 1.录入学生成绩。");
System.out.println(" 2.查看学生成绩。");
System.out.println(" 3.退出系统。");
System.out.println();
System.out.println(" 请选择您要的操作(1-3):");
sel = sc.nextInt();
switch (sel) {
case 1: {
for (int i = 0; i < 3; i++) {
stu_score[i][0] = i + 1;
}
for (int i = 0, a = 1; i < 3; i++) {
System.out.println("请输入第" + a + "个学生的成绩:");
a++;
System.out.println();
for (int j = 1, b = 1; j < 4; j++) {
System.out.println("请输入第" + b + "门课程的成绩:");
b++;
stu_score[i][j] = sc.nextInt();
}
}
break;}
case 2: {
for (int i = 0; i < 6; i++) {
System.out.print(" " + stu_score_name[i]);
}
System.out.println();
for (int i = 0; i <3; i++) {
for (int j = 0; j < 4; j++) {
System.out.print(" " + stu_score[i][j]);
}
stu_score[i][4] = stu_score[i][1] + stu_score[i][2] + stu_score[i][3];
System.out.print(" " + stu_score[i][4]);
stu_score[i][5] = (stu_score[i][1] + stu_score[i][2] + stu_score[i][3]) / 3;
System.out.print(" " + stu_score[i][5]);
System.out.println();}
break;}
case 3:
break;
default:
System.out.println("程序出错!");
}} while (sel != 3);
if (sel == 3) {
break;}}}}
怎么添加三个门课程的总分、平均分
展开