用户注册



邮箱:

密码:

用户登录


邮箱:

密码:
记住登录一个月忘记密码?

发表随想


还能输入:200字
云代码 - java代码库

学生成绩管理系统

2016-11-22 作者: java程序设计举报

[java]代码库

package com.student.www;
 
import java.util.Scanner;
 
public class StudentCJInput {
 
    String[][] studentcjs = null;// 所有学生的成绩数组对应每个学生
    String studentNames[] = null;// 所有学生数组
    String[] cjs = null;// 科目数组
 
    int studentNum = 0;// 学生数
    int keNum = 0;// 学生科目数
    Scanner scanner;// 监听系统输入
 
    public StudentCJInput(int sNum, int keNum) {
        scanner = new Scanner(System.in);
        this.studentNum = sNum;
        this.keNum = keNum;
        showCJ();
    }
 
    /**
     * 输入成绩
     *
     */
    void showCJ() {
        studentNames = new String[studentNum];
        studentcjs = new String[studentNum][keNum];
        cjs = new String[keNum];
        System.out.println("请依次输入所有学科:");
        for (int xk = 0; xk < cjs.length; xk++) {
            System.out.println("请输入第" + (xk + 1) + "门学科名:");
            String xkName = scanner.next();
            cjs[xk] = xkName;
        }
        for (int name = 0; name < studentNames.length; name++) {
            System.out.println("请输入第" + (name + 1) + "个学生的姓名:");
            String sName = scanner.next();
            studentNames[name] = sName;
            String[] scjNum = studentcjs[name];
            for (int yxk = 0; yxk < cjs.length; yxk++) {
                System.out.println("请输入" + cjs[yxk] + "的成绩:");
                String cNum = scanner.next();
                scjNum[yxk] = cNum;
            }
        }
        print();
    }
 
    /**
     * 打印
     */
    private void print() {
        System.out.println("所有学生的成绩单:");
        System.out.print("\t");
        printStudentName();
        printCJNUM();
        printZCJ();
        printPJCJ();
        printJB();     
    }
 
    /**
     * 打印学生姓名
     */
    private void printStudentName() {
        for (int i = 0; i < studentNames.length; i++) {
            System.out.print(studentNames[i] + "\t");
        }
    }
 
    /**
     * 打印成绩分数
     */
    private void printCJNUM() {
        for (int i = 0; i < cjs.length; i++) {
            System.out.print("\n" + cjs[i] + "\t");
            for (int j = 0; j < studentNames.length; j++) {
                String[] cj = studentcjs[j];
                for (int l = 0; l < cj.length; l++) {
                    if (l == i) {
                        System.out.print(cj[l] + "\t");
                    }
                }
            }
        }
    }
 
    /**
     * 打印总成绩
     */
    private void printZCJ() {
        System.out.println();
        System.out.print("总成绩\t");
        for (int i = 0; i < studentNames.length; i++) {
            String cj[] = studentcjs[i];
            int cjNum = 0;
            for (int j = 0; j < cj.length; j++) {
                cjNum += Integer.parseInt(cj[j]);
            }
            System.out.print((cjNum) + "\t");
        }
    }
 
    /**
     * 平均成绩打印
     */
    private void printPJCJ() {
        System.out.println();
        System.out.print("平均成绩\t");
        for (int i = 0; i < studentNames.length; i++) {
            String cj[] = studentcjs[i];
            int cjNum = 0;
            for (int j = 0; j < cj.length; j++) {
                cjNum += Integer.parseInt(cj[j]);
            }
            System.out.print((cjNum / cj.length) + "\t");
        }
    }
 
    /**
     * 打印级别
     */
    public void printJB() {
        System.out.println();
        System.out.print("评级\t");
        for (int i = 0; i < studentNames.length; i++) {
            String cj[] = studentcjs[i];
            int cjNum = 0;
            for (int j = 0; j < cj.length; j++) {
                cjNum += Integer.parseInt(cj[j]);
            }
            String ylc = getJi(cjNum / cj.length);
            System.out.print(ylc + "\t");
        }
    }
 
    /**
     * 获得级别差
     *
     * @param i
     * @return
     */
    public final static String Y = "优";
    public final static String L = "良";
    public final static String C = "差";
    public final static String BJG = "不及格";
 
    private String getJi(int ylc) {
        if (ylc < 60) {
            return BJG;
        } else if (ylc >= 60 && ylc < 70) {
            return C;
        } else if (ylc >= 70 && ylc < 90) {
            return L;
        } else if (ylc >= 90 && ylc <= 100) {
            return Y;
        }
        return BJG;
    }
 
}
 
 
 
 
 
 
 
 
package com.student.www;
 
import java.util.Scanner;
 
public class Main {
 
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入学生数:");
        int snum = scanner.nextInt();
        System.out.println("请输入科目数:");
        int knum = scanner.nextInt();
        StudentCJInput studentCJInput = new StudentCJInput(snum, knum);
    }
}


网友评论    (发表评论)

共2 条评论 1/1页

发表评论:

评论须知:

  • 1、评论每次加2分,每天上限为30;
  • 2、请文明用语,共同创建干净的技术交流环境;
  • 3、若被发现提交非法信息,评论将会被删除,并且给予扣分处理,严重者给予封号处理;
  • 4、请勿发布广告信息或其他无关评论,否则将会删除评论并扣分,严重者给予封号处理。


扫码下载

加载中,请稍后...

输入口令后可复制整站源码

加载中,请稍后...