Java student achievement management system course design, with source code!

Village rain 2021-04-08 11:01:36
java student achievement management course


Preface

For computer majors , I must be very impressed with the course design of student achievement management system . Design 、 operate a computer 、 code 、 Write a report 、 Defense and a series of other processes , Although it's very simple , But we can also use some of the knowledge we have learned .

Let's review the following topic today , use Java SE To achieve this task , It's a pity that I didn't write well in class .

Although it's very simple , But for those who are new to programming , There's still some difficulty , We should consider the interface printing , We should also consider the judgment of conditions 、 Loop statement 、 I / O control and so on , So here's a simple implementation , Convenient for beginners to learn a reference ( As for my ugly interface , Don't get too tangled , You can adjust it yourself , We only focus on function implementation ).

For student achievement management system , It can be divided into the following functions :

  1. Enter student scores
  2. Count the student's scores
  3. Find student grades
  4. Revise student grades
  5. Delete student grades
  6. Sort by average
  7. Show all grades
  8. Exit the management system

After entering the system , We should have a system menu , Then select the operation we want to do according to the prompt .

  • Enter student scores

This function is to input the student's score information every time , Or on the basis of the current data, add and enter new student achievement information ;

  • Count the student's scores

It's mainly about the statistics of students' achievements , And then output the average score , And print out the corresponding information ;

image-20210405133413661
image-20210405133413661
  • Find student grades

According to the input student number to find the corresponding student's relevant score information ;

  • Revise student grades

According to the input student number to modify the corresponding student's grades ;

  • Delete student grades

According to the input student number , Delete the corresponding student's grade information ;

  • Sort by average

In descending order of average score ;

image-20210405135553488
image-20210405135553488
  • Show all grades

Convenient for all student grades , Then print it out ;

  • Exit the management system

Exit menu ;

Function design and implementation

main interface

Mainly print out the selection menu of system function , Then according to our input into different sub function modules ;

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】 Enter student scores -------------");
            System.out.println("-------------【2】 Show statistics -------------");
            System.out.println("-------------【3】 Find student grades -------------");
            System.out.println("-------------【4】 Revise student grades -------------");
            System.out.println("-------------【5】 Delete student grades -------------");
            System.out.println("-------------【6】 On average -------------");
            System.out.println("-------------【7】 Show all grades -------------");
            System.out.println("-------------【0】 Exit the 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":
                    //  Search for grades
                    student.lookupStudent(students);
                    break;
                case "4":
                    //  Revise grades
                    student.modifyStudent(students);
                    break;
                case "5":
                    //  Delete grades
                    student.deleteStudent(students);
                    break;
                case "6":
                    //  Sort by average
                    student.sortStudent(students);
                    break;
                case "7":
                    //  Show all grades
                    student.showAllStudent(students);
                    break;
                case "0":
                    System.exit(0);
                default:
                    break;
            }
        }
    }
}

Main class design

The system is mainly aimed at the management of student achievement information , So we design a student class , It includes a series of attributes ( That is, simple personal information and scores of various subjects );

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


public class Student {
    //     class
    private String grade;
    //     Student number
    private long id;
    //     full name
    private String name;
    //     Advanced Mathematics
    private float math;
    //     English
    private float english;
    //     sports
    private float sport;
    //    Java
    private float java;
    //    C++
    private float cPlusPlus;
    //     Politics
    private float polity;
    //     Algorithm
    private float algorithm;
    //     average
    private double average;
    
    //  Various  setter/getter  And constructors
}

Enter student scores

First, enter the student number , Determine if it is available , If it is not available, re-enter , If available, enter other information ;

Then assign the information to the student object , Finally, add the student object to the collection .

/**
@param students  Student object list
@return
@description  Enter student information
@date 2021/4/5 9:14
@author cunyu1943
@version 1.0
*/

public void addScore(ArrayList<Student> students) {
    System.out.println("---------- Enter student data ----------");
    System.out.println(" Please input the following data in turn :");
    long id;
    while (true) {
        System.out.println(" Student number ");
        id = scanner.nextInt();
        if (isValid(students, id)) {
            System.out.println(" Repeat the student number , Please re-enter ");
        } else {
            break;
        }
    }

    System.out.println(" grade ");
    String grade = scanner.next();
    System.out.println(" full 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(" Politics ");
    float polity = scanner.nextFloat();
    System.out.println(" Algorithm ");
    float algorithm = scanner.nextFloat();

    //         Create objects , And set properties , Then 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 an average
    double avg = getAvg(student);
    student.setAverage(avg);
    //         Add to collection
    students.add(student);
    //         Prompt information
    System.out.println(" Add success ");
}

Count the student's scores

Mainly realize the statistics of the average score of each student , And print out the information ;

/**
@param students  Student object set
@return
@description  Show simple statistics
@date 2021/4/5 10:08
@author cunyu1943
@version 1.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 full name \t\t average ");
        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));
        }
    }
}

Find student grades

First, judge whether there is data , Follow up operation when there is data . Then match the input student number , Find the student grade information of the corresponding student number and print it ;

/**
@param students  Student object set
@return
@description  Find the score information of the corresponding student number
@date 2021/4/5 12:59
@author cunyu1943
@version 1.0
*/

public void lookupStudent(ArrayList<Student> students) {
    System.out.println("---------- Find student grades ----------");
    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 want to search for :");
        long id = scanner.nextLong();
        int flag = -1;
        Student student = new Student();
        //         Find the corresponding student number , Find and quit
        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(" No student with corresponding student number was found , Please confirm and re-enter !");
        } else {
            System.out.println(" The results of the students corresponding to the student number are as follows :");
            System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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(" Find information successfully !");
        }
    }

}

Revise student grades

First, judge whether there is data , Follow up operation when there is data . Then match the input student number , Find the student with the corresponding student number , And then modify the score information , But don't modify other personal information ;

/**
@param students  Student object set
@return
@description  Modify the information of the corresponding student number
@date 2021/4/5 12:59
@author cunyu1943
@version 1.0
*/

public void modifyStudent(ArrayList<Student> students) {
    System.out.println("---------- Revise student grades ----------");
    if (students.isEmpty()) {
        System.out.println(" Currently no data , Please add and try again ");
    } else {
        System.out.println(" Please input the student number of the student to be modified :");
        long id = scanner.nextLong();

        for (Student student : students) {
            if (id == student.getId()) {
                System.out.println(" Please re-enter the student's grade ");
                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(" Politics ");
                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 an average
                double avg = getAvg(student);
                student.setAverage(avg);
                System.out.println(" Modification successful !");
            } else {
                System.out.println(" No student with corresponding student number was found , Please confirm and re-enter !");
            }
            break;
        }
    }
}

Delete student grades

First, judge whether there is data , Follow up operation when there is data . Then match the input student number , Find the student with the corresponding student number , Then delete it from the collection ;

/**
     * @param students  Student object set
     * @return
     * @description  Delete student grades
     * @date 2021/4/5 14:28
     * @author cunyu1943
     * @version 1.0
     */

public void deleteStudent(ArrayList<Student> students) {
    System.out.println("---------- Delete student grades ----------");
    if (students.isEmpty()) {
        System.out.println(" Currently no data , Please add and try again ");
    } else {
        System.out.println(" Enter the student number to delete the student grade ");
        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(" No student information of corresponding student number was found , Please confirm before deleting !");
        } else {
            students.remove(index);
            System.out.println("---------- Delete successful ----------");
        }
    }
}

Sort by average

First, judge whether there is data , Follow up operation when there is data . And then sort the average scores of the students in the set , Then print out the student information from high to low in turn ;

/**
@param students  Student object set
@return
@description  Sort by average
@date 2021/4/5 14:29
@author cunyu1943
@version 1.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(" The student's grades after ranking ");
        System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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));
        }
    }
}

Show all grades

First, judge whether there is data , Follow up operation when there is data . Traverse the collection of student objects , Then print out the score information of each student .

/**
@param students  Student object set
@return
@description  Show all student grades
@date 2021/4/5 14:30
@author cunyu1943
@version 1.0
*/

public void showAllStudent(ArrayList<Student> students) {
    if (students.isEmpty()) {
        System.out.println(" Currently no data , Please add data first ");
    } else {
        System.out.println("---------- The results of all the students are as follows ----------");
        System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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));
        }
    }
}

General procedure

After integrating all the above modules , 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】 Enter student scores -------------");
            System.out.println("-------------【2】 Show statistics -------------");
            System.out.println("-------------【3】 Find student grades -------------");
            System.out.println("-------------【4】 Revise student grades -------------");
            System.out.println("-------------【5】 Delete student grades -------------");
            System.out.println("-------------【6】 On average -------------");
            System.out.println("-------------【7】 Show all grades -------------");
            System.out.println("-------------【0】 Exit the 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 "7":
                    student.showAllStudent(students);
                    break;
                case "0":
                    System.exit(0);
                default:
                    break;
            }
        }
    }
}

  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 23:31
 * @description :  Students
 */


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

    public Student() {
    }

    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() {
        return grade;
    }

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

    public long getId() {
        return id;
    }

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

    public String getName() {
        return name;
    }

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

    public float getMath() {
        return math;
    }

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

    public float getEnglish() {
        return english;
    }

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

    public float getSport() {
        return sport;
    }

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

    public float getJava() {
        return java;
    }

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

    public float getcPlusPlus() {
        return cPlusPlus;
    }

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

    public float getPolity() {
        return polity;
    }

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

    public float getAlgorithm() {
        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;
    }


    /**
     * @param students  Student object list
     * @return
     * @description  Enter student information
     * @date 2021/4/5 9:14
     * @author cunyu1943
     * @version 1.0
     */

    public void addScore(ArrayList<Student> students) {
        System.out.println("---------- Enter student data ----------");
        System.out.println(" Please input the following data in turn :");
        long id;
        while (true) {
            System.out.println(" Student number ");
            id = scanner.nextInt();
            if (isValid(students, id)) {
                System.out.println(" Repeat the student number , Please re-enter ");
            } else {
                break;
            }
        }

        System.out.println(" grade ");
        String grade = scanner.next();
        System.out.println(" full 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(" Politics ");
        float polity = scanner.nextFloat();
        System.out.println(" Algorithm ");
        float algorithm = scanner.nextFloat();

        //         Create objects , And set properties , Then 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 an average
        double avg = getAvg(student);
        student.setAverage(avg);
        //         Add to collection
        students.add(student);
        //         Prompt information
        System.out.println(" Add success ");
    }

    /**
     * @param students  Student object set
     * @param id        Student number
     * @return true, Repeat the student number ;false  Student number is available
     * @description  Judge whether the student number is available
     * @date 2021/4/5 9:19
     * @author cunyu1943
     * @version 1.0
     */

    public boolean isValid(ArrayList<Student> students, long id) {
        for (Student student : students) {
            if (student.getId() == id) {
                return true;
            }
        }
        return false;
    }

    /**
     * @param students  Student object set
     * @return
     * @description  Show simple statistics
     * @date 2021/4/5 10:08
     * @author cunyu1943
     * @version 1.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 full name \t\t average ");
            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));
            }
        }
    }

    /**
     * @param students  Student object set
     * @return
     * @description  Find the score information of the corresponding student number
     * @date 2021/4/5 12:59
     * @author cunyu1943
     * @version 1.0
     */

    public void lookupStudent(ArrayList<Student> students) {
        System.out.println("---------- Find student grades ----------");
        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 want to search for :");
            long id = scanner.nextLong();
            int flag = -1;
            Student student = new Student();
            //         Find the corresponding student number , Find and quit
            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(" No student with corresponding student number was found , Please confirm and re-enter !");
            } else {
                System.out.println(" The results of the students corresponding to the student number are as follows :");
                System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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(" Find information successfully !");
            }
        }

    }

    /**
     * @param students  Student object set
     * @return
     * @description  Modify the information of the corresponding student number
     * @date 2021/4/5 12:59
     * @author cunyu1943
     * @version 1.0
     */

    public void modifyStudent(ArrayList<Student> students) {
        System.out.println("---------- Revise student grades ----------");
        if (students.isEmpty()) {
            System.out.println(" Currently no data , Please add and try again ");
        } else {
            System.out.println(" Please input the student number of the student to be modified :");
            long id = scanner.nextLong();

            for (Student student : students) {
                if (id == student.getId()) {
                    System.out.println(" Please re-enter the student's grade ");
                    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(" Politics ");
                    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 an average
                    double avg = getAvg(student);
                    student.setAverage(avg);
                    System.out.println(" Modification successful !");
                } else {
                    System.out.println(" No student with corresponding student number was found , Please confirm and re-enter !");
                }
                break;
            }
        }
    }


    /**
     * @param students  Student object set
     * @return
     * @description  Delete student grades
     * @date 2021/4/5 14:28
     * @author cunyu1943
     * @version 1.0
     */

    public void deleteStudent(ArrayList<Student> students) {
        System.out.println("---------- Delete student grades ----------");
        if (students.isEmpty()) {
            System.out.println(" Currently no data , Please add and try again ");
        } else {
            System.out.println(" Enter the student number to delete the student grade ");
            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(" No student information of corresponding student number was found , Please confirm before deleting !");
            } else {
                students.remove(index);
                System.out.println("---------- Delete successful ----------");
            }
        }
    }

    /**
     * @param students  Student object set
     * @return
     * @description  Show all student grades
     * @date 2021/4/5 14:30
     * @author cunyu1943
     * @version 1.0
     */

    public void showAllStudent(ArrayList<Student> students) {
        if (students.isEmpty()) {
            System.out.println(" Currently no data , Please add data first ");
        } else {
            System.out.println("---------- The results of all the students are as follows ----------");
            System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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));
            }
        }
    }

    /**
     * @param students  Student object set
     * @return
     * @description  Sort by average
     * @date 2021/4/5 14:29
     * @author cunyu1943
     * @version 1.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(" The student's grades after ranking ");
            System.out.println(" class \t\t Student number \t\t full name \t\t mathematics \t\t English \t\t sports \t\tJava\t\tC++\t\t Politics \t\t Algorithm \t\t 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));
            }
        }
    }

}

summary

Although the function is simple , But it will take some time to finish . Besides , This design is only for a running process , Once the program is terminated , The input data cannot be saved , This needs attention . Later, consider adding file writing or database to realize the course design , To save the data we entered .

版权声明
本文为[Village rain]所创,转载请带上原文链接,感谢
https://javamana.com/2021/04/20210408103155672g.html

  1. SCIP: constructing data abstraction -- Explanation of queue and tree in data structure
  2. Spring cloud + Nacos to implement service registry (Hoxton version)
  3. Installation and upgrade of rabbitmq server
  4. Lei Jun: Xiaomi's spring conference has been largely streamlined, which will take at least four hours. Some products will be directly released on Weibo
  5. IntelliJ IDEA 2021最新激活码(亲测有效,可激活至 2089 年)
  6. java版本spring cloud+spring boot+mybatis 分布式商城 微服务商城 多租户商城 电子商务 直播带货商城 社交电商
  7. win10安装Redis5.0
  8. (十五)springboot电子商务商城之SpringCloud-使用Eureka集群搭建实现高可用服务注册中心
  9. (十四)springboot电子商务商城之SpringCloud-Eureka自我保护模式和InstanceID的配置
  10. 花生壳内网穿透(Linux版)
  11. Docker部署elasticsearch(单机)
  12. (十三)springboot电子商务商城之SpringCloud-使用Eureka集群搭建实现高可用服务注册中心
  13. (十二)springboot电子商务商城之Eureka注册中心开启密码认证
  14. 七、Spring Boot 集成 Thymeleaf 模板引擎
  15. mysql 命令行秒复制数据库
  16. Windows安装Mysql(msi 图形安装)
  17. The latest activation code of IntelliJ idea 2021
  18. Java应用全链路启动速度提升至15s,阿里云SAE能力再升级
  19. Linux基础命令
  20. Who moved your red envelope? Risk control report of 2021 spring festival activities
  21. Java version spring cloud + spring boot + mybatis distributed mall micro Service Mall multi tenant mall e-commerce live delivery mall social E-commerce
  22. Java 任意音频转MP3
  23. Docker 的 DNS
  24. Docker-搭建日志监控系统
  25. ssm+mysql+maven+shiro进销存系统wms
  26. Installing redis5.0 on win10
  27. (15) Springcloud of springboot E-commerce mall - using Eureka cluster to build and implement high availability service registry
  28. (14) Springcloud Eureka self protection mode and instanceid configuration of springboot E-commerce mall
  29. Peanut shell intranet penetration (Linux version)
  30. Deploying elastic search with docker (stand alone)
  31. (13) Springcloud of springboot E-commerce mall - using Eureka cluster to build and implement high availability service registry
  32. (12) Eureka registry of springboot E-commerce mall opens password authentication
  33. 爱上 Java 的10 大理由!
  34. 7、 Spring boot integrates thymeleaf template engine
  35. 【DB宝41】监控利器PMM的使用--监控MySQL、PG、MongoDB、ProxySQL等
  36. 【DB宝42】MySQL高可用架构MHA+ProxySQL实现读写分离和负载均衡
  37. MySQL command line second replication database
  38. Windows installation of MySQL (MSI graphic installation)
  39. The full link startup speed of Java applications has been increased to 15s, and the SAE capability of alicloud has been upgraded again
  40. Java 学生成绩管理系统课程设计,附源码!
  41. Linux basic command
  42. Java arbitrary audio to MP3
  43. DNS of docker
  44. Docker - build log monitoring system
  45. SSM + MySQL + Maven + Shiro WMS
  46. Top 10 reasons to fall in love with java!
  47. 一本关于HTTP的恋爱日记
  48. 【RocketMQ源码分析】深入消息存储(3)
  49. SpringCloud+Nacos实现服务配置中心(Hoxton版本)
  50. SCIP:构造数据抽象--数据结构中队列与树的解释
  51. SCIP:构造过程抽象--面向对象的解释
  52. 使用 docker 进行 ElasticSearch + Kibana 集群搭建
  53. Spring IOC 特性有哪些,不会读不懂源码!
  54. [DB Bao 41] use of PMM -- monitoring mysql, PG, mongodb, proxysql, etc
  55. Spring Cloud 升级之路 - 2020.0.x - 3. Undertow 的 accesslog 配置
  56. [DB Bao 42] MySQL high availability architecture MHA + proxysql realizes read-write separation and load balancing
  57. [DataGuard] recovery of physical DG in case of losing archive files in main database (7)
  58. MyBatis(3)Map和模糊查询拓展
  59. 【TTS】AIX-&gt;Linux--基于RMAN(真实环境)
  60. 【TTS】传输表空间AIX-&gt;linux基于rman