[Java] 学生成绩管理系统 →→→→→进入此内容的聊天室

来自 , 2020-05-04, 写在 Java, 查看 117 次.
URL http://www.code666.cn/view/db6ebd05
  1. package com.student.www;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class StudentCJInput {
  6.  
  7.         String[][] studentcjs = null;// 所有学生的成绩数组对应每个学生
  8.         String studentNames[] = null;// 所有学生数组
  9.         String[] cjs = null;// 科目数组
  10.  
  11.         int studentNum = 0;// 学生数
  12.         int keNum = 0;// 学生科目数
  13.         Scanner scanner;// 监听系统输入
  14.  
  15.         public StudentCJInput(int sNum, int keNum) {
  16.                 scanner = new Scanner(System.in);
  17.                 this.studentNum = sNum;
  18.                 this.keNum = keNum;
  19.                 showCJ();
  20.         }
  21.  
  22.         /**
  23.          * 输入成绩
  24.          *
  25.          */
  26.         void showCJ() {
  27.                 studentNames = new String[studentNum];
  28.                 studentcjs = new String[studentNum][keNum];
  29.                 cjs = new String[keNum];
  30.                 System.out.println("请依次输入所有学科:");
  31.                 for (int xk = 0; xk < cjs.length; xk++) {
  32.                         System.out.println("请输入第" + (xk + 1) + "门学科名:");
  33.                         String xkName = scanner.next();
  34.                         cjs[xk] = xkName;
  35.                 }
  36.                 for (int name = 0; name < studentNames.length; name++) {
  37.                         System.out.println("请输入第" + (name + 1) + "个学生的姓名:");
  38.                         String sName = scanner.next();
  39.                         studentNames[name] = sName;
  40.                         String[] scjNum = studentcjs[name];
  41.                         for (int yxk = 0; yxk < cjs.length; yxk++) {
  42.                                 System.out.println("请输入" + cjs[yxk] + "的成绩:");
  43.                                 String cNum = scanner.next();
  44.                                 scjNum[yxk] = cNum;
  45.                         }
  46.                 }
  47.                 print();
  48.         }
  49.  
  50.         /**
  51.          * 打印
  52.          */
  53.         private void print() {
  54.                 System.out.println("所有学生的成绩单:");
  55.                 System.out.print("\t");
  56.                 printStudentName();
  57.                 printCJNUM();
  58.                 printZCJ();
  59.                 printPJCJ();
  60.                 printJB();             
  61.         }
  62.  
  63.         /**
  64.          * 打印学生姓名
  65.          */
  66.         private void printStudentName() {
  67.                 for (int i = 0; i < studentNames.length; i++) {
  68.                         System.out.print(studentNames[i] + "\t");
  69.                 }
  70.         }
  71.  
  72.         /**
  73.          * 打印成绩分数
  74.          */
  75.         private void printCJNUM() {
  76.                 for (int i = 0; i < cjs.length; i++) {
  77.                         System.out.print("\n" + cjs[i] + "\t");
  78.                         for (int j = 0; j < studentNames.length; j++) {
  79.                                 String[] cj = studentcjs[j];
  80.                                 for (int l = 0; l < cj.length; l++) {
  81.                                         if (l == i) {
  82.                                                 System.out.print(cj[l] + "\t");
  83.                                         }
  84.                                 }
  85.                         }
  86.                 }
  87.         }
  88.  
  89.         /**
  90.          * 打印总成绩
  91.          */
  92.         private void printZCJ() {
  93.                 System.out.println();
  94.                 System.out.print("总成绩\t");
  95.                 for (int i = 0; i < studentNames.length; i++) {
  96.                         String cj[] = studentcjs[i];
  97.                         int cjNum = 0;
  98.                         for (int j = 0; j < cj.length; j++) {
  99.                                 cjNum += Integer.parseInt(cj[j]);
  100.                         }
  101.                         System.out.print((cjNum) + "\t");
  102.                 }
  103.         }
  104.  
  105.         /**
  106.          * 平均成绩打印
  107.          */
  108.         private void printPJCJ() {
  109.                 System.out.println();
  110.                 System.out.print("平均成绩\t");
  111.                 for (int i = 0; i < studentNames.length; i++) {
  112.                         String cj[] = studentcjs[i];
  113.                         int cjNum = 0;
  114.                         for (int j = 0; j < cj.length; j++) {
  115.                                 cjNum += Integer.parseInt(cj[j]);
  116.                         }
  117.                         System.out.print((cjNum / cj.length) + "\t");
  118.                 }
  119.         }
  120.  
  121.         /**
  122.          * 打印级别
  123.          */
  124.         public void printJB() {
  125.                 System.out.println();
  126.                 System.out.print("评级\t");
  127.                 for (int i = 0; i < studentNames.length; i++) {
  128.                         String cj[] = studentcjs[i];
  129.                         int cjNum = 0;
  130.                         for (int j = 0; j < cj.length; j++) {
  131.                                 cjNum += Integer.parseInt(cj[j]);
  132.                         }
  133.                         String ylc = getJi(cjNum / cj.length);
  134.                         System.out.print(ylc + "\t");
  135.                 }
  136.         }
  137.  
  138.         /**
  139.          * 获得级别差
  140.          *
  141.          * @param i
  142.          * @return
  143.          */
  144.         public final static String Y = "优";
  145.         public final static String L = "良";
  146.         public final static String C = "差";
  147.         public final static String BJG = "不及格";
  148.  
  149.         private String getJi(int ylc) {
  150.                 if (ylc < 60) {
  151.                         return BJG;
  152.                 } else if (ylc >= 60 && ylc < 70) {
  153.                         return C;
  154.                 } else if (ylc >= 70 && ylc < 90) {
  155.                         return L;
  156.                 } else if (ylc >= 90 && ylc <= 100) {
  157.                         return Y;
  158.                 }
  159.                 return BJG;
  160.         }
  161.  
  162. }
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171. package com.student.www;
  172.  
  173. import java.util.Scanner;
  174.  
  175. public class Main {
  176.  
  177.         public static void main(String[] args) {
  178.                 Scanner scanner = new Scanner(System.in);
  179.                 System.out.println("请输入学生数:");
  180.                 int snum = scanner.nextInt();
  181.                 System.out.println("请输入科目数:");
  182.                 int knum = scanner.nextInt();
  183.                 StudentCJInput studentCJInput = new StudentCJInput(snum, knum);
  184.         }
  185. }
  186.  

回复 "学生成绩管理系统"

这儿你可以回复上面这条便签

captcha