java用数组查询成绩_java怎么用数组计算学生成绩

/*/**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;}}}}

怎么添加三个门课程的总分、平均分

展开

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值