java编写一个学生成绩管理系统,java学生成绩录入系统

  java编写一个学生成绩管理系统,java学生成绩录入系统

  本文实例为大家分享了爪哇岛学生成绩档案管理系统的具体代码,供大家参考,具体内容如下

  学生成绩档案管理系统源代码:

  student

  公共类学生{私有字符串名称;私有字符串编号;private int chinascore private int mathscore private int englishscore private int physcore public students(String name,String number,int China score,int math score,int English score,int physcore){ this。name=名称;this.number=数字;这个。中国得分=中国得分;这个。数学成绩=数学成绩;这个。英语成绩=英语成绩;this . phys core=phys core } public String getName(){ return name;} public void set name(String name){ this。name=名称;}公共字符串get number(){返回数字;}公共void集号(字符串号){ this。数=数;} public int get China score(){ return China score;} public void set China score(int China score){ this。中国得分=中国得分;} public int get math score(){ return math score;} public void setmath score(int math score){ this。数学成绩=数学成绩;} public int get English score(){ return English score;} public void set English score(int English score){ this。英语成绩=英语成绩;} public int getPhyscore(){ return physcore;} public void setPhyscore(int physcore){ this。physcore=physcore} }database

  导入Java。util。ArrayList导入Java。util。列表;公共类数据库{ list students students list=new ArrayList();公共数据库(){学生列表。添加(新生(张三, 1, 1, 1, 1, 1));学生列表.添加(新学生(李四, 2, 8, 2, 2, 2));学生列表.添加(新学生(王五, 3, 1, 3, 3, 3));学生列表.添加(新学生(赵六, 4, 6, 4, 4, 4));} public list学生获取学生列表(){返回学生列表;} public void set students list(list students students list){ this。学生列表=学生列表;} }studentdao

  导入Java。util。列表;导入java.ut

  il.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:           &      

	  
	  
	  
	  
	  
	  
        

郑重声明:本文由网友发布,不代表盛行IT的观点,版权归原作者所有,仅为传播更多信息之目的,如有侵权请联系,我们将第一时间修改或删除,多谢。

留言与评论(共有 条评论)
   
验证码: