preface

For the students of computer major, the course design of student achievement management system must be very impressive. Design, computer, coding, report writing, defense and a series of processes, although very simple, but also can comprehensively use some of the knowledge we have learned.

Today to review the following topic, using Java SE to achieve the topic, but also to make up the original class did not write a good regret.

Although very simple, but to just dabble in programming learning, or has the certain difficulty, should not only consider print interface, also want to consider condition judgment, looping statements, input and output control, and so on techniques, so simply implemented here, convenient for beginners friends to a reference (interface is ugly to my problem, don’t too entanglements, Go down can adjust 😂, we only focus on function implementation 🤣).

For the student score management system, it can be divided into the following functions:

  1. Record student scores
  2. Student performance statistics
  3. Find student scores
  4. Revision of student grades
  5. Delete student scores
  6. Sort by average
  7. Show all grades
  8. Exiting the management System

Once in the system, we should have the system menu, and then follow the prompts to choose what we want to do.

  • Record student scores

The function is to input students’ performance information every time, or add input new student performance information on the basis of the current data;

  • Student performance statistics

It mainly carries on the statistics to the student’s achievement, then outputs the average score, and prints out the corresponding information;

  • Find student scores

According to the input student number to find the corresponding students related results information;

  • Revision of student grades

According to the input student number to modify the corresponding student’s score;

  • Delete student scores

According to the student id, delete the corresponding student’s score information;

  • Sort by average

In descending order of average score;

  • Show all grades

Facilitate all student scores and then print them out;

  • Exiting the management System

Exit menu;

Function design and implementation

The main interface

It is mainly to print out the selection menu of system functions, and then enter different sub-function modules according to our input;

package com.cunyu;

import java.util.ArrayList;
import java.util.Scanner;

/ * * *@author : cunyu
 * @version : 1.0
 * @className : Manager
 * @date : 2021/4/4 23:54
 * @description: Management system */

public class Manager {
    public static Scanner scanner = new Scanner(System.in);
    public static ArrayList<Student> students = new ArrayList<>();

    public static void main(String[] args) {
        while (true) {
            System.out.println("---------- Welcome to the student Achievement Management system -----------");
            System.out.println("------------- [1] Input student scores -------------");
            System.out.println("------------- [2] display statistics -------------");
            System.out.println("------------- [3] find student scores -------------");
            System.out.println("------------- [4] Modify student grades -------------");
            System.out.println("------------- [5] delete student scores -------------");
            System.out.println("------------- [6] in average order -------------");
            System.out.println("------------- [7] display all grades -------------");
            System.out.println("------------- [0] Exit management system -------------");

            Student student = new Student();

            System.out.println("Enter your choice [0-7]");
            String choice = scanner.next();
            switch (choice) {
                case "1":
                    // Enter the score
                    student.addScore(students);
                    break;
                case "2":
                    // Statistics
                    student.showAvg(students);
                    break;
                case "3":
                    // find the result
                    student.lookupStudent(students);
                    break;
                case "4":
                    // Modify the score
                    student.modifyStudent(students);
                    break;
                case "5":
                    // Delete the result
                    student.deleteStudent(students);
                    break;
                case "6":
                    // Sort by average
                    student.sortStudent(students);
                    break;
                case "Seven":
                    // Display all results
                    student.showAllStudent(students);
                    break;
                case "0":
                    System.exit(0);
                default:
                    break; }}}}Copy the code

The main class design

The system is mainly for the management of student performance information, so we design a student class, including a series of attributes (that is, simple personal information and scores of each subject);

package com.cunyu;
/ * * *@author : cunyu
 * @version : 1.0
 * @className : Student
 * @date: 2021/4/4 for *@description: Student */

public class Student {
    / / class
    private String grade;
    / / student id
    private long id;
    / / name
    private String name;
    / / high number
    private float math;
    / / English
    private float english;
    / / sports
    private float sport;
    // Java
    private float java;
    // C++
    private float cPlusPlus;
    / / political
    private float polity;
    / / algorithm
    private float algorithm;
    / / average
    private double average;
    
    // Various setters/getters and constructors
}
Copy the code

Record student scores

First input student number, judge whether available, not available to re-input, available input other information;

Then assign the information to the student object, and finally add the student object to the collection.

/ * * *@paramStudents List of student objects *@return
* @descriptionInput student information *@date 2021/4/5 9:14
* @author cunyu1943
* @version1.0 * /
public void addScore(ArrayList<Student> students) {
    System.out.println("---------- Enter student data ----------");
    System.out.println("Please enter the following data successively:");
    long id;
    while (true) {
        System.out.println("Student id");
        id = scanner.nextInt();
        if (isValid(students, id)) {
            System.out.println("Student number repeated, please re-enter.");
        } else {
            break;
        }
    }

    System.out.println("Grade");
    String grade = scanner.next();
    System.out.println("Name");
    String name = scanner.next();
    System.out.println("Mathematics");
    float math = scanner.nextFloat();
    System.out.println("English");
    float english = scanner.nextFloat();
    System.out.println("Sports");
    float sport = scanner.nextFloat();
    System.out.println("Java");
    float java = scanner.nextFloat();
    System.out.println("C++");
    float cPlusPlus = scanner.nextFloat();
    System.out.println("Political");
    float polity = scanner.nextFloat();
    System.out.println("Algorithm");
    float algorithm = scanner.nextFloat();

    // Create an object, set its properties, and add it to the student object collection
    Student student = new Student();
    student.setId(id);
    student.setGrade(grade);
    student.setName(name);
    student.setMath(math);
    student.setAlgorithm(algorithm);
    student.setEnglish(english);
    student.setcPlusPlus(cPlusPlus);
    student.setJava(java);
    student.setSport(sport);
    student.setPolity(polity);
    // Get the average score
    double avg = getAvg(student);
    student.setAverage(avg);
    // Add to collection
    students.add(student);
    // Prompt message
    System.out.println("Added successfully");
}
Copy the code

Student performance statistics

The main realization of the average score statistics for each student, and then print out the information;

/ * * *@paramStudents Collection of student objects *@return
* @descriptionDisplay simple statistics *@date2021/4/5 * at 10:08@author cunyu1943
* @version1.0 * /
public void showAvg(ArrayList<Student> students) {
    System.out.println("---------- Output student statistics ----------");
    if (students.size() == 0) {
        System.out.println("Currently no data, please add data first!");
    } else {
        System.out.println("Class, t, T Student number, T, T name, T average score");
        System.out.println("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
        for (Student student : students) {
            System.out.format("%s\t\t%d\t\t%s\t\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getAvg(student)); }}}Copy the code

Find student scores

Check whether there is data before performing subsequent operations. Then through the input of student number matching, find the corresponding student score information and print;

/ * * *@paramStudents Collection of student objects *@return
* @descriptionFind the student's grade information *@date2021/4/5 thou *@author cunyu1943
* @version1.0 * /
public void lookupStudent(ArrayList<Student> students) {
    System.out.println("---------- find student scores ----------");
    if (students.size() == 0) {
        System.out.println("Currently no data, please add and try again");
    } else {
        System.out.println(Please enter the student ID of the student you are looking for:);
        long id = scanner.nextLong();
        int flag = -1;
        Student student = new Student();
        // Find the corresponding student id and exit
        for (int i = 0; i < students.size(); i++) {
            student = students.get(i);
            if (student.getId() == id) {
                flag = i;
                break; }}if (flag == -1) {
            System.out.println("Not found the corresponding student number, please confirm and re-enter!");
        } else {
            System.out.println("The result of the student corresponding to the student number is as follows:");
            System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
            System.out.format("%s\t%d\t\t%s\t\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student));
            System.out.println("Information found successfully!"); }}}Copy the code

Revision of student grades

Check whether there is data before performing subsequent operations. Then through the input of the student number to match, find the corresponding student number, and then modify the performance information, but do not modify other personal information;

/ * * *@paramStudents Collection of student objects *@return
* @descriptionModify the information of the corresponding student id *@date2021/4/5 thou *@author cunyu1943
* @version1.0 * /
public void modifyStudent(ArrayList<Student> students) {
    System.out.println("---------- modify student grades ----------");
    if (students.isEmpty()) {
        System.out.println("Currently no data, please add and try again");
    } else {
        System.out.println(Please enter the student ID of the student you want to change:);
        long id = scanner.nextLong();

        for (Student student : students) {
            if (id == student.getId()) {
                System.out.println("Please re-enter this student's score");
                System.out.println("Mathematics");
                float math = scanner.nextFloat();
                System.out.println("English");
                float english = scanner.nextFloat();
                System.out.println("Sports");
                float sport = scanner.nextFloat();
                System.out.println("Java");
                float java = scanner.nextFloat();
                System.out.println("C++");
                float cPlusPlus = scanner.nextFloat();
                System.out.println("Political");
                float polity = scanner.nextFloat();
                System.out.println("Algorithm");
                float algorithm = scanner.nextFloat();

                student.setMath(math);
                student.setAlgorithm(algorithm);
                student.setEnglish(english);
                student.setcPlusPlus(cPlusPlus);
                student.setJava(java);
                student.setSport(sport);
                student.setPolity(polity);
                // Get the average score
                double avg = getAvg(student);
                student.setAverage(avg);
                System.out.println("Modification successful!");
            } else {
                System.out.println("Not found the corresponding student number, please confirm and re-enter!");
            }
            break; }}}Copy the code

Delete student scores

Check whether there is data before performing subsequent operations. Then through the input student number to match, find the corresponding student number, and then delete it from the set;

/ * * *@paramStudents Collection of student objects *@return
     * @descriptionDelete student grades *@date14:28 2021/4/5 *@author cunyu1943
     * @version1.0 * /
public void deleteStudent(ArrayList<Student> students) {
    System.out.println("---------- delete student scores ----------");
    if (students.isEmpty()) {
        System.out.println("Currently no data, please add and try again");
    } else {
        System.out.println("Enter the student ID to delete the student's score");
        long id = scanner.nextLong();

        int index = -1;
        for (int i = 0; i < students.size(); i++) {
            Student student = students.get(i);
            if (student.getId() == id) {
                index = i;
                break; }}if (index == -1) {
            System.out.println("Did not find the corresponding student number information, please confirm and then delete!");
        } else {
            students.remove(index);
            System.out.println("---------- deleted successfully ----------"); }}}Copy the code

Sort by average

Check whether there is data before performing subsequent operations. Then the average score of the students in the set is sorted, and then the students’ information is printed from high to low.

/ * * *@paramStudents Collection of student objects *@return
* @descriptionIn order of average *@date2021/4/5 land *@author cunyu1943
* @version1.0 * /
public void sortStudent(ArrayList<Student> students) {
    if (students.isEmpty()) {
        System.out.println("Currently no data, please add and try again");
    } else {
        for (int i = 0; i < students.size() - 1; i++) {
            if (students.get(i).getAvg(students.get(i)) < students.get(i + 1).getAvg(students.get(i + 1))) {
                Student tmp = students.get(i);
                students.set(i, students.get(i + 1));
                students.set(i + 1, tmp);
            }
        }

        System.out.println("Ranked student scores.");
        System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
        for (Student student : students) {
            System.out.format("%s\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student)); }}}Copy the code

Show all grades

Check whether there is data before performing subsequent operations. Iterate over the student object collection, and then print out the score information for each student.

/ * * *@paramStudents Collection of student objects *@return
* @descriptionDisplay all student scores *@date2021/4/5 comes to *@author cunyu1943
* @version1.0 * /
public void showAllStudent(ArrayList<Student> students) {
    if (students.isEmpty()) {
        System.out.println("Currently no data, please add data first");
    } else {
        System.out.println("---------- All students scored below ----------");
        System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
        for (Student student : students) {
            System.out.format("%s\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student)); }}}Copy the code

The total program

After putting all the above modules together, we get the final program;

  1. Manager.java
package com.cunyu;

import java.util.ArrayList;
import java.util.Scanner;

/ * * *@author : cunyu
 * @version : 1.0
 * @className : Manager
 * @date : 2021/4/4 23:54
 * @description: Management system */

public class Manager {
    public static Scanner scanner = new Scanner(System.in);
    public static ArrayList<Student> students = new ArrayList<>();

    public static void main(String[] args) {
        while (true) {
            System.out.println("---------- Welcome to the student Achievement Management system -----------");
            System.out.println("------------- [1] Input student scores -------------");
            System.out.println("------------- [2] display statistics -------------");
            System.out.println("------------- [3] find student scores -------------");
            System.out.println("------------- [4] Modify student grades -------------");
            System.out.println("------------- [5] delete student scores -------------");
            System.out.println("------------- [6] in average order -------------");
            System.out.println("------------- [7] display all grades -------------");
            System.out.println("------------- [0] Exit management system -------------");

            Student student = new Student();

            System.out.println("Enter your choice");
            String choice = scanner.next();
            switch (choice) {
                case "1":
                    student.addScore(students);
                    break;
                case "2":
                    student.showAvg(students);
                    break;
                case "3":
                    student.lookupStudent(students);
                    break;
                case "4":
                    student.modifyStudent(students);
                    break;
                case "5":
                    student.deleteStudent(students);
                    break;
                case "6":
                    student.sortStudent(students);
                    break;
                case "Seven":
                    student.showAllStudent(students);
                    break;
                case "0":
                    System.exit(0);
                default:
                    break; }}}}Copy the code
  1. Student.java
package com.cunyu;

import java.util.ArrayList;
import java.util.Scanner;

/ * * *@author : cunyu
 * @version : 1.0
 * @className : Student
 * @date: 2021/4/4 for *@description: Student */

public class Student {
    public static Scanner scanner = new Scanner(System.in);
    / / class
    private String grade;
    / / student id
    private long id;
    / / name
    private String name;
    / / high number
    private float math;
    / / English
    private float english;
    / / sports
    private float sport;
    // Java
    private float java;
    // C++
    private float cPlusPlus;
    / / political
    private float polity;
    / / algorithm
    private float algorithm;
    / / average
    private double average;

    public Student(a) {}public Student(String grade, long id, String name, float math, float english, float sport, float java, float cPlusPlus, float polity, float algorithm, double average) {
        this.grade = grade;
        this.id = id;
        this.name = name;
        this.math = math;
        this.english = english;
        this.sport = sport;
        this.java = java;
        this.cPlusPlus = cPlusPlus;
        this.polity = polity;
        this.algorithm = algorithm;
        this.average = average;
    }

    public String getGrade(a) {
        return grade;
    }

    public void setGrade(String grade) {
        this.grade = grade;
    }

    public long getId(a) {
        return id;
    }

    public void setId(long id) {
        this.id = id;
    }

    public String getName(a) {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public float getMath(a) {
        return math;
    }

    public void setMath(float math) {
        this.math = math;
    }

    public float getEnglish(a) {
        return english;
    }

    public void setEnglish(float english) {
        this.english = english;
    }

    public float getSport(a) {
        return sport;
    }

    public void setSport(float sport) {
        this.sport = sport;
    }

    public float getJava(a) {
        return java;
    }

    public void setJava(float java) {
        this.java = java;
    }

    public float getcPlusPlus(a) {
        return cPlusPlus;
    }

    public void setcPlusPlus(float cPlusPlus) {
        this.cPlusPlus = cPlusPlus;
    }

    public float getPolity(a) {
        return polity;
    }

    public void setPolity(float polity) {
        this.polity = polity;
    }

    public float getAlgorithm(a) {
        return algorithm;
    }

    public void setAlgorithm(float algorithm) {
        this.algorithm = algorithm;
    }

    public double getAvg(Student student) {
        return (student.getAlgorithm() + student.getcPlusPlus() + student.getEnglish() + student.getSport() + student.getJava() + student.getPolity() + student.getMath()) / 7;
    }

    public void setAverage(double average) {
        this.average = average;
    }


    / * * *@paramStudents List of student objects *@return
     * @descriptionInput student information *@date 2021/4/5 9:14
     * @author cunyu1943
     * @version1.0 * /
    public void addScore(ArrayList<Student> students) {
        System.out.println("---------- Enter student data ----------");
        System.out.println("Please enter the following data successively:");
        long id;
        while (true) {
            System.out.println("Student id");
            id = scanner.nextInt();
            if (isValid(students, id)) {
                System.out.println("Student number repeated, please re-enter.");
            } else {
                break;
            }
        }

        System.out.println("Grade");
        String grade = scanner.next();
        System.out.println("Name");
        String name = scanner.next();
        System.out.println("Mathematics");
        float math = scanner.nextFloat();
        System.out.println("English");
        float english = scanner.nextFloat();
        System.out.println("Sports");
        float sport = scanner.nextFloat();
        System.out.println("Java");
        float java = scanner.nextFloat();
        System.out.println("C++");
        float cPlusPlus = scanner.nextFloat();
        System.out.println("Political");
        float polity = scanner.nextFloat();
        System.out.println("Algorithm");
        float algorithm = scanner.nextFloat();

        // Create an object, set its properties, and add it to the student object collection
        Student student = new Student();
        student.setId(id);
        student.setGrade(grade);
        student.setName(name);
        student.setMath(math);
        student.setAlgorithm(algorithm);
        student.setEnglish(english);
        student.setcPlusPlus(cPlusPlus);
        student.setJava(java);
        student.setSport(sport);
        student.setPolity(polity);
        // Get the average score
        double avg = getAvg(student);
        student.setAverage(avg);
        // Add to collection
        students.add(student);
        // Prompt message
        System.out.println("Added successfully");
    }

    / * * *@paramStudents Collection of student objects *@paramId student id *@returnTrue, student number repeated; False The student ID can be *@descriptionCheck whether the student id is available *@date 2021/4/5 9:19
     * @author cunyu1943
     * @version1.0 * /
    public boolean isValid(ArrayList<Student> students, long id) {
        for (Student student : students) {
            if (student.getId() == id) {
                return true; }}return false;
    }

    / * * *@paramStudents Collection of student objects *@return
     * @descriptionDisplay simple statistics *@date2021/4/5 * at 10:08@author cunyu1943
     * @version1.0 * /
    public void showAvg(ArrayList<Student> students) {
        System.out.println("---------- Output student statistics ----------");
        if (students.size() == 0) {
            System.out.println("Currently no data, please add data first!");
        } else {
            System.out.println("Class, t, T Student number, T, T name, T average score");
            System.out.println("-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --");
            for (Student student : students) {
                System.out.format("%s\t\t%d\t\t%s\t\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getAvg(student)); }}}/ * * *@paramStudents Collection of student objects *@return
     * @descriptionFind the student's grade information *@date2021/4/5 thou *@author cunyu1943
     * @version1.0 * /
    public void lookupStudent(ArrayList<Student> students) {
        System.out.println("---------- find student scores ----------");
        if (students.size() == 0) {
            System.out.println("Currently no data, please add and try again");
        } else {
            System.out.println(Please enter the student ID of the student you are looking for:);
            long id = scanner.nextLong();
            int flag = -1;
            Student student = new Student();
            // Find the corresponding student id and exit
            for (int i = 0; i < students.size(); i++) {
                student = students.get(i);
                if (student.getId() == id) {
                    flag = i;
                    break; }}if (flag == -1) {
                System.out.println("Not found the corresponding student number, please confirm and re-enter!");
            } else {
                System.out.println("The result of the student corresponding to the student number is as follows:");
                System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
                System.out.format("%s\t%d\t\t%s\t\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student));
                System.out.println("Information found successfully!"); }}}/ * * *@paramStudents Collection of student objects *@return
     * @descriptionModify the information of the corresponding student id *@date2021/4/5 thou *@author cunyu1943
     * @version1.0 * /
    public void modifyStudent(ArrayList<Student> students) {
        System.out.println("---------- modify student grades ----------");
        if (students.isEmpty()) {
            System.out.println("Currently no data, please add and try again");
        } else {
            System.out.println(Please enter the student ID of the student you want to change:);
            long id = scanner.nextLong();

            for (Student student : students) {
                if (id == student.getId()) {
                    System.out.println("Please re-enter this student's score");
                    System.out.println("Mathematics");
                    float math = scanner.nextFloat();
                    System.out.println("English");
                    float english = scanner.nextFloat();
                    System.out.println("Sports");
                    float sport = scanner.nextFloat();
                    System.out.println("Java");
                    float java = scanner.nextFloat();
                    System.out.println("C++");
                    float cPlusPlus = scanner.nextFloat();
                    System.out.println("Political");
                    float polity = scanner.nextFloat();
                    System.out.println("Algorithm");
                    float algorithm = scanner.nextFloat();

                    student.setMath(math);
                    student.setAlgorithm(algorithm);
                    student.setEnglish(english);
                    student.setcPlusPlus(cPlusPlus);
                    student.setJava(java);
                    student.setSport(sport);
                    student.setPolity(polity);
                    // Get the average score
                    double avg = getAvg(student);
                    student.setAverage(avg);
                    System.out.println("Modification successful!");
                } else {
                    System.out.println("Not found the corresponding student number, please confirm and re-enter!");
                }
                break; }}}/ * * *@paramStudents Collection of student objects *@return
     * @descriptionDelete student grades *@date14:28 2021/4/5 *@author cunyu1943
     * @version1.0 * /
    public void deleteStudent(ArrayList<Student> students) {
        System.out.println("---------- delete student scores ----------");
        if (students.isEmpty()) {
            System.out.println("Currently no data, please add and try again");
        } else {
            System.out.println("Enter the student ID to delete the student's score");
            long id = scanner.nextLong();

            int index = -1;
            for (int i = 0; i < students.size(); i++) {
                Student student = students.get(i);
                if (student.getId() == id) {
                    index = i;
                    break; }}if (index == -1) {
                System.out.println("Did not find the corresponding student number information, please confirm and then delete!");
            } else {
                students.remove(index);
                System.out.println("---------- deleted successfully ----------"); }}}/ * * *@paramStudents Collection of student objects *@return
     * @descriptionDisplay all student scores *@date2021/4/5 comes to *@author cunyu1943
     * @version1.0 * /
    public void showAllStudent(ArrayList<Student> students) {
        if (students.isEmpty()) {
            System.out.println("Currently no data, please add data first");
        } else {
            System.out.println("---------- All students scored below ----------");
            System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
            for (Student student : students) {
                System.out.format("%s\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student)); }}}/ * * *@paramStudents Collection of student objects *@return
     * @descriptionIn order of average *@date2021/4/5 land *@author cunyu1943
     * @version1.0 * /
    public void sortStudent(ArrayList<Student> students) {
        if (students.isEmpty()) {
            System.out.println("Currently no data, please add and try again");
        } else {
            for (int i = 0; i < students.size() - 1; i++) {
                if (students.get(i).getAvg(students.get(i)) < students.get(i + 1).getAvg(students.get(i + 1))) {
                    Student tmp = students.get(i);
                    students.set(i, students.get(i + 1));
                    students.set(i + 1, tmp);
                }
            }

            System.out.println("Ranked student scores.");
            System.out.println("Class student id \ \ \ t t t t \ t \ \ t name math \ t \ \ t t English \ t \ \ t sports tJava political \ \ tC++ \ t \ \ t t t t \ t \ \ t algorithm average." ");
            for (Student student : students) {
                System.out.format("%s\t%d\t%s\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\t%.2f\n", student.getGrade(), student.getId(), student.getName(), student.getMath(), student.getEnglish(), student.getSport(), student.getJava(), student.getcPlusPlus(), student.getPolity(), student.getAlgorithm(), student.getAvg(student)); }}}}Copy the code

conclusion

Although the function is relatively simple, but still need a certain amount of time to complete. In addition, this design is only for a running process, once the program terminates, the input data can not be saved, this point needs to be noted. Later, we will consider adding file writing or database to realize the course design, so as to save the data we have entered.