91超碰碰碰碰久久久久久综合_超碰av人澡人澡人澡人澡人掠_国产黄大片在线观看画质优化_txt小说免费全本

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

java怎么實現簡單學生成績檔案管理系統

發布時間:2022-05-30 16:26:11 來源:億速云 閱讀:115 作者:iii 欄目:開發技術

今天小編給大家分享一下java怎么實現簡單學生成績檔案管理系統的相關知識點,內容詳細,邏輯清晰,相信大部分人都還太了解這方面的知識,所以分享這篇文章給大家參考一下,希望大家閱讀完這篇文章后有所收獲,下面我們一起來了解一下吧。

學生成績檔案管理系統源代碼:

student

public class students{
    private String name;
    private String number;
    private int chinascore;
    private int mathscore;
    private int englishscore;
    private int physcore;

    public students(String name, String number, int chinascore, int mathscore, int englishscore, int physcore) {
        this.name = name;
        this.number = number;
        this.chinascore = chinascore;
        this.mathscore = mathscore;
        this.englishscore = englishscore;
        this.physcore = physcore;
    }

    public String getName() {
        return name;
    }

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

    public String getNumber() {
        return number;
    }

    public void setNumber(String number) {
        this.number = number;
    }

    public int getChinascore() {
        return chinascore;
    }

    public void setChinascore(int chinascore) {
        this.chinascore = chinascore;
    }

    public int getMathscore() {
        return mathscore;
    }

    public void setMathscore(int mathscore) {
        this.mathscore = mathscore;
    }

    public int getEnglishscore() {
        return englishscore;
    }

    public void setEnglishscore(int englishscore) {
        this.englishscore = englishscore;
    }

    public int getPhyscore() {
        return physcore;
    }

    public void setPhyscore(int physcore) {
        this.physcore = physcore;
    }
}

database

import java.util.ArrayList;
import java.util.List;

public class database {
    List<students> studentsList = new ArrayList<>();
    public database() {
        studentsList.add(new students("張三", "1", 1, 1, 1, 1));
        studentsList.add(new students("李四", "2", 8, 2, 2, 2));
        studentsList.add(new students("王五", "3", 1, 3, 3, 3));
        studentsList.add(new students("趙六", "4", 6, 4, 4, 4));
    }
    public List<students> getStudentsList() {
        return studentsList;
    }
    public void setStudentsList(List<students> studentsList) {
        this.studentsList = studentsList;
    }
}

studentdao

import java.util.List;
import java.util.Scanner;

public class studentdao {
    database database;

    public studentdao(database dataBase) {
        this.database = dataBase;
    }

    //對全部學生信息打印
    public void print() {
        List<students> list = database.getStudentsList();
        System.out.println("學生學號:" + "學生姓名" + "  語文:" + "數學:" + "英語:" + "物理:"+"學生總分");
        for (students students : database.getStudentsList()) {
            int x=students.getChinascore()+students.getMathscore()+students.getEnglishscore()+students.getPhyscore();
            System.out.println("" + students.getNumber() + "     " + students.getName() + "     " + students.getChinascore()
                    + "    " + students.getMathscore() + "   " + students.getEnglishscore() + "    " + students.getPhyscore()+"     "+x);
        }
        for(int i=0;i<=list.size();i++){
            int x=list.get(i).getChinascore()+list.get(i).getMathscore() +list.get(i).getEnglishscore()+list.get(i).getPhyscore();
            System.out.println((i+1)+list.get(i).getNumber()+list.get(i).getName()+list.get(i).getChinascore()+list.get(i).getMathscore() +list.get(i).getEnglishscore()+list.get(i).getPhyscore() +x);
        }
    }

    //添加新的學生
    public void add() {
        String number;
        String name;
        int grade1;
        int grade2;
        int grade3;
        int grade4;
        Scanner scanner = new Scanner(System.in);
        System.out.println("輸入學生的學號:");
        number = scanner.next();
        System.out.println("輸入學生的姓名:");
        name = scanner.next();
        System.out.println("輸入學生的語文成績:");
        grade1 = scanner.nextInt();
        System.out.println("輸入學生的數學成績:");
        grade2 = scanner.nextInt();
        System.out.println("輸入學生的英語成績:");
        grade3 = scanner.nextInt();
        System.out.println("輸入學生的物理成績:");
        grade4 = scanner.nextInt();
        students students = new students(name, number, grade1, grade2, grade3, grade4);
        List<students> studentsList = database.getStudentsList();
        studentsList.add(students);
    }

    //輸入姓名或者學號來查詢學生信息
    public void searchstudent() {
        Scanner scanner = new Scanner(System.in);
            findbynumber();
    }
    //通過輸入學號來查詢信息
    public void findbynumber() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("輸入學生的學號:");
        String number = scanner.next();
        for (students students : database.getStudentsList()) {
            if (students.getNumber().equals(number)) {
                System.out.println("學生學號:" + students.getNumber() + "學生姓名:" + students.getName()
                        + "語文:" + students.getChinascore() + "數學:" + students.getMathscore()
                        + "英語:" + students.getEnglishscore() + "物理:" + students.getPhyscore());
            }
        }
    }
    //通過學號來修改科目成績
    public void changescore() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("輸入學號:");
        String number = scanner.next();
        students students = null;
        for (students a : database.getStudentsList()) {
            if (a.getNumber().equals(number)) {
                students = a;
            }
        }
        if (students != null) {
            System.out.println("查找成功!");
            System.out.println("學生學號:" + students.getNumber() + "學生姓名:" + students.getName()
                    + "語文:" + students.getChinascore() + "數學:" + students.getMathscore()
                    + "英語:" + students.getEnglishscore() + "物理:" + students.getPhyscore());
            System.out.println("輸入要修改的語文的成績:");
            int grade1 = scanner.nextInt();
            System.out.println("輸入要修改的數學的成績:");
            int grade2 = scanner.nextInt();
            System.out.println("輸入要修改的英語的成績:");
            int grade3 = scanner.nextInt();
            System.out.println("輸入要修改的物理的成績:");
            int grade4 = scanner.nextInt();
            students.setChinascore(grade1);
            students.setMathscore(grade2);
            students.setEnglishscore(grade3);
            students.setPhyscore(grade4);
            System.out.println("修改完成!");
            System.out.println("學生學號:" + students.getNumber() + "學生姓名:" + students.getName()
                    + "語文:" + students.getChinascore() + "數學:" + students.getMathscore()
                    + "英語:" + students.getEnglishscore() + "物理:" + students.getPhyscore());
        } else {
            System.out.println("未找到該學生!");
        }
    }
    //雙向冒泡排序
    public List<students> bub(List<students> studentList) {
        List<students> list = database.getStudentsList();
        students student = null;
        int left = 0, right = database.getStudentsList().size() - 1;
        while (left < right) {
            for (int i = left + 1; i <= right; i++) {
                if (list.get(left).getChinascore() + list.get(left).getMathscore() + list.get(left).getEnglishscore() + list.get(left).getPhyscore() < list.get(i).getChinascore() + list.get(i).getMathscore() + list.get(i).getEnglishscore() + list.get(i).getPhyscore()) {
                    student = list.get(i);
                    list.set(i, list.get(left));
                    list.set(left, student);

                }
            }
            left++;
            for (int i = right - 1; i >= left; i--) {
                if (list.get(right).getChinascore() + list.get(right).getMathscore() + list.get(right).getEnglishscore() + list.get(right).getPhyscore() > list.get(i).getChinascore() + list.get(i).getMathscore() + list.get(i).getEnglishscore() + list.get(i).getPhyscore()) {
                    {
                        student = list.get(i);
                        list.set(i, list.get(right));
                        list.set(right, student);
                    }
                }
                right--;
            }
        }


        return list;
    }
        //希爾排序
        public void shellSort () {
            List<students> list = database.getStudentsList();
            students student = null;
            students student1 = null;
            int j;
            for (int gap = list.size() / 2; gap > 0; gap /= 2) {
                for (int i = gap; i < list.size(); i++) {
                    student = list.get(i);
                    int tmp = student.getChinascore() + student.getMathscore() + student.getEnglishscore() + student.getPhyscore();
                    for (j = i; j >= gap && tmp > list.get(j - gap).getChinascore() + list.get(j - gap).getMathscore() + list.get(j - gap).getEnglishscore() + list.get(j - gap).getPhyscore(); j -= gap) {
                        list.set(j, list.get(j - gap));
                    }
                    list.set(j, student);
                }
            }

        }

        //快速排序
        public void quickSort1 ( int left, int right){
            List<students> studentsList = database.getStudentsList();
            if (left < right) {
                int i = left, j = right;
                students student = studentsList.get(left);
                int x = student.getChinascore() + student.getMathscore() + student.getEnglishscore() + student.getPhyscore();
                while (i < j) {
                    while ((i < j) && (studentsList.get(j).getChinascore() + studentsList.get(j).getMathscore() + studentsList.get(j).getEnglishscore() + studentsList.get(j).getPhyscore()) < x) {
                        j--;
                    }
                    if (i < j) {
                        studentsList.set(i, studentsList.get(j));
                        i++;
                    }
                    while ((i < j) && (studentsList.get(i).getChinascore() + studentsList.get(i).getMathscore() + studentsList.get(i).getEnglishscore() + studentsList.get(i).getPhyscore() > x)) {
                        i++;
                    }
                    if (i < j) {
                        studentsList.set(j, studentsList.get(i));
                        j--;
                    }
                }
                studentsList.set(i, student);
                quickSort1(left, i - 1);
                quickSort1(i + 1, right);
            }

        }
        //堆排序
    //移除位在第一個數據的根節點,并做最大堆調整的遞歸運算
public List<students> heapSort(List<students> studentList){
    List<students> list=studentList;
    int len = list.size();
    buildMaxHeap(list, len);
    for (int i = len - 1; i > 0; i--) {
        swap(list, 0, i);
        len--;
        heapify(list, 0, len);
    }
    return list;
}
//將堆中的所有數據重新排序堆排序(HeapSort)
    private void buildMaxHeap(List<students> studentList, int len) {
        for (int i = (int) Math.floor(len / 2); i >= 0; i--) {
            heapify(studentList, i, len);
        }
    }

    private void heapify(List<students> studentList, int i, int len) {
        int left = 2 * i + 1;
        int right = 2 * i + 2;
        int largest = i;

        if (left < len && studentList.get(left).getChinascore() + studentList.get(left).getMathscore() + studentList.get(left).getEnglishscore() + studentList.get(left).getPhyscore()< studentList.get(largest).getChinascore() + studentList.get(largest).getMathscore() + studentList.get(largest).getEnglishscore() + studentList.get(largest).getPhyscore()) {
            largest = left;
        }

        if (right < len && studentList.get(right).getChinascore() + studentList.get(right).getMathscore() + studentList.get(right).getEnglishscore() + studentList.get(right).getPhyscore()< studentList.get(largest).getChinascore() + studentList.get(largest).getMathscore() + studentList.get(largest).getEnglishscore() + studentList.get(largest).getPhyscore()) {
            largest = right;
        }

        if (largest != i) {
            swap(studentList, i, largest);
            heapify(studentList, largest, len);
        }
    }
    private void swap(List<students> studentList, int i, int j) {
        students student=studentList.get(i);
        studentList.set(i,studentList.get(j));
        studentList.set(j,student);
    }
    }

service

import java.util.Scanner;

public class service {
    private studentdao studentdao;
    ;
    private database database;

    public service(database dataBase) {
        studentdao = new studentdao(dataBase);

        this.database = dataBase;
    }
    public void start() {
        Scanner scanner = new Scanner(System.in);
        System.out.println("1.增加學生信息");
        System.out.println("2.瀏覽學生信息");
        System.out.println("3.修改學生成績");
        System.out.println("4.排序學生成績");
        System.out.println("5.學生信息查詢");

        int choice = scanner.nextInt();
        switch (choice) {
            case 1:
                add();
                break;
            case 2:
                studentdao.print();
                System.out.println("是否回到主界面0.回到1.不會");
                int k=scanner.nextInt();
                if(k==0) {
                    start();
                }
                break;
            case 3:
                changeit();break;
            case 4:
                rank();
                break;
            case 5:
                search();break;
        }
    }
    //選擇排序方式
    public void rank(){
        System.out.println("1.希爾排序");
        System.out.println("2.冒泡排序");
        System.out.println("3.快速排序");
        System.out.println("4.堆排序");
        System.out.println("輸入0返回菜單");
        Scanner scanner = new Scanner(System.in);
        int a=scanner.nextInt();
        switch (a){
            case 1:
                studentdao.shellSort();
                studentdao.print();
                System.out.println("是否回到主界面0.回到1.不會");
                int p=scanner.nextInt();
                if(p==0) {
                    start();
                }
                break;
            case 2:
                studentdao.bub(database.getStudentsList());
                studentdao.print();

                System.out.println("是否回到主界面0.回到1.不會");
                int k=scanner.nextInt();
                if(k==0) {
                    start();
                }
                break;
            case 3:
                studentdao.quickSort1(0,database.getStudentsList().size()-1);
                studentdao.print();
                System.out.println("是否回到主界面0.回到1.不會");
                int o=scanner.nextInt();
                if(o==0) {
                    start();
                }
                break;
            case 4:
                studentdao.heapSort(database.getStudentsList());
                studentdao.print();
                System.out.println("是否回到主界面0.回到1.不會");
                int k1=scanner.nextInt();
                if(k1==0) {
                    start();
                }
                break;
            case 0:start();
                break;
        }
    }
    //查找學生信息
    public void search(){
        studentdao.searchstudent();
        Scanner scanner=new Scanner(System.in);
        System.out.println("是否回到主界面0.回到1.不會");
        int k=scanner.nextInt();
        if(k==0) {
            start();
        }
    }
    //更改學生信息

    public void changeit(){
            studentdao.changescore();
        System.out.println("是否回到主界面0.回到1.不會");
        Scanner scanner=new Scanner(System.in);
        int k=scanner.nextInt();
        if(k==0) {
            start();
        }
    }
    //增加學生
    public void add(){
        studentdao.add();
        System.out.println("是否回到主界面0.回到1.不會");
        Scanner scanner=new Scanner(System.in);
        int k=scanner.nextInt();
        if(k==0) {
            start();
        }
    }

}

text

public class text {
    public static void main(String[]args){
        database database = new database();
        service studentsSer=new service(database);
       studentsSer.start();
    }
}

以上就是“java怎么實現簡單學生成績檔案管理系統”這篇文章的所有內容,感謝各位的閱讀!相信大家閱讀完這篇文章都有很大的收獲,小編每天都會為大家更新不同的知識,如果還想學習更多的知識,請關注億速云行業資訊頻道。

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

叶城县| 虎林市| 长泰县| 新龙县| 丹东市| 尚义县| 衡东县| 屏东县| 华阴市| 静宁县| 井研县| 罗山县| 乡宁县| 西畴县| 新昌县| 班戈县| 北票市| 张家界市| 修武县| 阿巴嘎旗| 开江县| 沧源| 连州市| 化隆| 巴彦淖尔市| 临清市| 武隆县| 海南省| 玉树县| 连山| 萍乡市| 颍上县| 黄浦区| 彰武县| 霍林郭勒市| 凤庆县| 巴青县| 云安县| 界首市| 安西县| 余庆县|