<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
本文範例為大家分享了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(); } }
以上就是本文的全部內容,希望對大家的學習有所幫助,也希望大家多多支援it145.com。
相關文章
<em>Mac</em>Book项目 2009年学校开始实施<em>Mac</em>Book项目,所有师生配备一本<em>Mac</em>Book,并同步更新了校园无线网络。学校每周进行电脑技术更新,每月发送技术支持资料,极大改变了教学及学习方式。因此2011
2021-06-01 09:32:01
综合看Anker超能充系列的性价比很高,并且与不仅和iPhone12/苹果<em>Mac</em>Book很配,而且适合多设备充电需求的日常使用或差旅场景,不管是安卓还是Switch同样也能用得上它,希望这次分享能给准备购入充电器的小伙伴们有所
2021-06-01 09:31:42
除了L4WUDU与吴亦凡已经多次共事,成为了明面上的厂牌成员,吴亦凡还曾带领20XXCLUB全队参加2020年的一场音乐节,这也是20XXCLUB首次全员合照,王嗣尧Turbo、陈彦希Regi、<em>Mac</em> Ova Seas、林渝植等人全部出场。然而让
2021-06-01 09:31:34
目前应用IPFS的机构:1 谷歌<em>浏览器</em>支持IPFS分布式协议 2 万维网 (历史档案博物馆)数据库 3 火狐<em>浏览器</em>支持 IPFS分布式协议 4 EOS 等数字货币数据存储 5 美国国会图书馆,历史资料永久保存在 IPFS 6 加
2021-06-01 09:31:24
开拓者的车机是兼容苹果和<em>安卓</em>,虽然我不怎么用,但确实兼顾了我家人的很多需求:副驾的门板还配有解锁开关,有的时候老婆开车,下车的时候偶尔会忘记解锁,我在副驾驶可以自己开门:第二排设计很好,不仅配置了一个很大的
2021-06-01 09:30:48
不仅是<em>安卓</em>手机,苹果手机的降价力度也是前所未有了,iPhone12也“跳水价”了,发布价是6799元,如今已经跌至5308元,降价幅度超过1400元,最新定价确认了。iPhone12是苹果首款5G手机,同时也是全球首款5nm芯片的智能机,它
2021-06-01 09:30:45