2022年java学生管理系统源代码 .pdf

上传人:Che****ry 文档编号:27253345 上传时间:2022-07-23 格式:PDF 页数:17 大小:95.71KB
返回 下载 相关 举报
2022年java学生管理系统源代码 .pdf_第1页
第1页 / 共17页
2022年java学生管理系统源代码 .pdf_第2页
第2页 / 共17页
点击查看更多>>
资源描述

《2022年java学生管理系统源代码 .pdf》由会员分享,可在线阅读,更多相关《2022年java学生管理系统源代码 .pdf(17页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。

1、import java.io.Serializable; public class Course implements Serializable private String courseName; private int courseGrade; Course() courseName=null; courseGrade=0; public void setCourseNameValue(String ss) this.courseName=ss; public void setCourseGradeValue(int dd) this.courseGrade=dd; public Stri

2、ng getCourseNameValue() return this.courseName; public int getCourseGradeValue() return this.courseGrade; public boolean equals(Object o) if (o = null) return false; else if (o instanceof Course) Course rec = (Course) o; if (this.courseName.equals(rec.getCourseNameValue() return true; return false;

3、- 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 17 页 - - - - - - - - - import java.io.Serializable; import java.util.Arrays; import java.util.LinkedList; import java.util.List; public class Student implements Serializable, Comparable private String studentName

4、; private int studentId; /private int studentCourseAmount=4; private LinkedList courseList; Student() studentName=null; studentId=0; courseList=new LinkedList(); public void setStudentNameValue(String name)/ 确定学生名称this.studentName=name; public void setStudentIdValue(int id)/确定学生学号this.studentId=id;

5、public void setStudentCourseList(LinkedList list)/传入课程链list this.courseList=list; / System.out.println( 例: 0916 张磊语文98 数学67); public void setCourseGrade(Object o)/ 将与学科o 同名的学科的成绩改为o 的成绩for(int i=0;ithis.courseList.size();i+) Course obj=new Course(); obj=(Course) this.courseList.get(i); if(obj.equals

6、(o) Course res=(Course) o; obj.setCourseGradeValue(res.getCourseGradeValue(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 17 页 - - - - - - - - - public String getStudentNameValue()/ 取得学生姓名return this.studentName; public int getStudentId()/ 取得学生学号return this.

7、studentId; public LinkedList getstudentCourseList()/得到成绩链的首地址return this.courseList; public long getStudentCourseGrade(Course o)/ 取得与 o 同名的成绩值,尚有错误long temp = 0; List courTemp=this.getstudentCourseList(); Course obj; /System.out.println(courTemp.indexOf(o); int i=courTemp.indexOf(o); obj=(Course) co

8、urTemp.get(i); temp=obj.getCourseGradeValue(); return temp; public boolean equals(Object o) / 判定两个对象是否相同,姓名或学号相同if (o = null) return false; else if (o instanceof Student) Student rec = (Student) o; System.out.println(rec.getStudentNameValue(); if (this.studentName.equals(rec.getStudentNameValue() |

9、this.studentId=rec.getStudentId() return true; return false; public int compareTo(Object O) Student obj=(Student) O; int thisSum=0; for(int i=0;ithis.courseList.size();i+) Course cour=(Course) this.courseList.get(i); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页

10、,共 17 页 - - - - - - - - - thisSum += cour.getCourseGradeValue(); int OSum=0; for(int i=0;iobj.getstudentCourseList().size();i+) Course cour=(Course) obj.getstudentCourseList().get(i); OSum += cour.getCourseGradeValue(); if(thisSumOSum) return 1; return 0; import java.awt.Color; import java.awt.Font;

11、 import java.io.BufferedReader; /import java.util.*; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.FileWriter; import java.io.IOException; import java.io.InputStreamReader; import java.io.PrintWriter; import java.io.Serializable; import java.sql.Date; import j

12、ava.text.DecimalFormat; import java.text.NumberFormat; import java.util.Arrays; import java.util.LinkedList; import java.util.List; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 4 页,共 17 页 - - - - - - - - - import java.util.Scanner; import java.util.*; import org.jf

13、ree.chart.ChartFactory; import org.jfree.chart.ChartFrame; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.NumberAxis; import org.jfree.chart.labels.StandardPieSectionLabelGenerator; import org.jfree.char

14、t.plot.CategoryPlot; import org.jfree.chart.plot.PiePlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.title.TextTitle; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.data.general.DefaultPieDataset; public class Teacher private String teacherName; priv

15、ate List studentList; Teacher() teacherName=null; studentList=new LinkedList(); public void setTeacherName(String name) this.teacherName=name; public void setStudentList(LinkedList list) this.studentList=list; public String getTeacherName() return this.teacherName; public List getStudentList() retur

16、n this.studentList; public void addStudent(Object o)/添加学生o /Date date=new Date(0); if(o!=null & (o instanceof Student) studentList.add(o); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 5 页,共 17 页 - - - - - - - - - /* String s = null; try FileWriter fw = new FileWrit

17、er(manager.log, true); PrintWriter log = new PrintWriter(fw); log.println(-); / log.println(this.getTeacherName(); Student stu=(Student) o; log.println( 添加学生 ); log.println(学号:+stu.getStudentId()+ +姓名: +stu.getStudentNameValue(); log.println(=+new Date( 0)+=); log.flush(); log.close(); catch (IOExce

18、ption e) e.printStackTrace(); */ public void toAddStudent(Scanner tempCourse) System.out.println( 输入要添加学生的学号,姓名,各科名称及成绩以空格分开 ); System.out.println( 例: 09001 朱良语文23 数学45 英语78); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String s = null; try

19、s = br.readLine(); tempCourse=new Scanner(s); Student stu = new Student(); if(tempCourse.hasNextInt() int stuId = tempCourse.nextInt(); if(tempCourse.hasNext() String stuName = tempCourse.next(); stu.setStudentNameValue(stuName); stu.setStudentIdValue(stuId); LinkedList objList=new LinkedList(); Str

20、ing courseName=null; int courseGrade=0; Course objCourse; while(tempCourse.hasNext() | tempCourse.hasNextInt() 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 6 页,共 17 页 - - - - - - - - - courseName=tempCourse.next(); courseGrade=tempCourse.nextInt(); objCourse=new Co

21、urse(); objCourse.setCourseNameValue(courseName); objCourse.setCourseGradeValue(courseGrade); objList.add(objCourse); stu.setStudentCourseList(objList); int k=0; for(int j=0;jthis.studentList.size();j+) Student cc=(Student) this.studentList.get(j); if(cc.getStudentId()=stu.getStudentId() k+; if(k=0)

22、 this.addStudent(stu); System.out.println( 添加成功 ); else System.out.println( 已存在该学号); this.toAddStudent(tempCourse); else System.out.println( 错误输入 ); this.toAddStudent(tempCourse); else System.out.println( 错误输入 ); this.toAddStudent(tempCourse); catch (IOException e) e.printStackTrace(); finally try b

23、r.close(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 7 页,共 17 页 - - - - - - - - - catch (IOException e) e.printStackTrace(); public void removeStudent(int id)/删除学号与id 相同的对象int index=-1; for(int i=0;ithis.studentList.size();i+) Student temp=(Student) this.student

24、List.get(i); if(temp.getStudentId() = id) index=i; if(index != -1) Student stu=(Student) this.studentList.get(index); this.studentList.remove(index); System.out.println( 删除成功 ); /*String s = null; try FileWriter fw = new FileWriter(manager.log, true); PrintWriter log = new PrintWriter(fw); log.print

25、ln(-); /log.println(this.getTeacherName(); / Student stu=(Student) o; log.println( 删除学生 ); log.println(学号:+stu.getStudentId()+ +姓名: +stu.getStudentNameValue(); log.println(=+new Date(0)+=); log.flush(); log.close(); catch (IOException e) e.printStackTrace(); */ else System.out.println( 不存在该学生); this

26、.toRemoveStudent(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 8 页,共 17 页 - - - - - - - - - public void toRemoveStudent() System.out.println( 输入要删除学生的学号); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); Strin

27、g s = null; try s = br.readLine(); Scanner tempCourse=new Scanner(s); if(tempCourse.hasNextInt() int stuId = tempCourse.nextInt(); this.removeStudent(stuId); else System.out.println( 错误输入 ); this.toRemoveStudent(); / int stuId = tempCourse.nextInt(); / this.removeStudent(stuId); catch (IOException e

28、) e.printStackTrace(); finally try br.close(); catch (IOException e) e.printStackTrace(); public void changeStudent(Student o)/ 与 o 学号或姓名一样的学生对象用o 替代int index=0; for(int i=0;ithis.studentList.size();i+) Student temp=(Student) this.studentList.get(i); if(temp.getStudentId() = o.getStudentId() | temp.

29、getStudentNameValue().equals(o.getStudentNameValue() index=i; break; Student stu=(Student) this.studentList.get(index); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 9 页,共 17 页 - - - - - - - - - this.studentList.set(index,o); /* String s = null; try FileWriter fw =

30、new FileWriter(manager.log, true); PrintWriter log = new PrintWriter(fw); log.println(-); /log.println(this.getTeacherName(); /Student stu=(Student) o; log.println( 修改学生信息); log.println(学号:+stu.getStudentId()+ +姓名: +stu.getStudentNameValue(); log.println(=+new Date(0)+=); log.flush(); log.close(); c

31、atch (IOException e) e.printStackTrace(); */ public void toChangeStudent() System.out.println( 输入要修改的学生的学号,姓名,各科名称及成绩以空格分开); System.out.println( 例: 09001 朱良语文23 数学45 英语78); InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr); String s = null; try s =

32、 br.readLine(); Scanner tempCourse=new Scanner(s); Student stu = new Student(); int stuId = tempCourse.nextInt(); String stuName = tempCourse.next(); stu.setStudentNameValue(stuName); stu.setStudentIdValue(stuId); LinkedList objList=new LinkedList(); String courseName=null; int courseGrade=0; Course

33、 objCourse; while(tempCourse.hasNext() | tempCourse.hasNextInt() courseName=tempCourse.next(); courseGrade=tempCourse.nextInt(); objCourse=new Course(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 10 页,共 17 页 - - - - - - - - - objCourse.setCourseNameValue(courseNa

34、me); objCourse.setCourseGradeValue(courseGrade); objList.add(objCourse); stu.setStudentCourseList(objList); this.changeStudent(stu); catch (IOException e) e.printStackTrace(); finally try br.close(); catch (IOException e) e.printStackTrace(); public void searchStudentById()/ 查找学号为id 的学生的信息 (学号, 姓名,各

35、科成绩)System.out.println( 输入学号: ); Scanner sc = new Scanner(System.in); int id = sc.nextInt(); int index=0; for(int i=0;ithis.studentList.size();i+) Student temp=(Student) this.studentList.get(i); if(temp.getStudentId() = id) index=i; Student sss=(Student) this.studentList.get(index); System.out.print

36、ln( 姓名:+sss.getStudentNameValue()+ ); System.out.println( 学号:+sss.getStudentId()+ ); LinkedList cour=new LinkedList(); cour=sss.getstudentCourseList(); for(int i=0;icour.size();i+) Course tempCourse=new Course(); tempCourse=(Course) cour.get(i); System.out.println(tempCourse.getCourseNameValue()+: +

37、tempCourse.getCourseGradeValue()+ ); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 11 页,共 17 页 - - - - - - - - - public void courseAverage()/ 计算单科平均分System.out.println( 输入课程名 ); Course o = new Course(); Scanner sc = new Scanner(System.in); String ss=sc.next(); o.set

38、CourseNameValue(ss); long sum=0; for(int i=0;ithis.studentList.size();i+) Student tempStu=(Student) this.studentList.get(i); sum=sum+tempStu.getStudentCourseGrade(o); double aver = (double) sum/this.studentList.size(); System.out.println(aver); public void makeOrderByGrades()/将学生信息按总成绩从小到大打印到控制台上Obj

39、ect stuArray=this.studentList.toArray(); Arrays.sort(stuArray); for(int i=0;istuArray.length;i+) Student tempStu=(Student) stuArrayi; System.out.print(tempStu.getStudentId()+ ); System.out.print(tempStu.getStudentNameValue()+ ); LinkedList cour=new LinkedList(); cour=tempStu.getstudentCourseList();

40、for(int j=0;jcour.size();j+) Course tempCourse=new Course(); tempCourse=(Course) cour.get(j); System.out.print(tempCourse.getCourseNameValue()+ +tempCourse.getCourseGradeValue()+ ); System.out.println(); public void toClear() this.studentList.clear(); String s = null; try 名师资料总结 - - -精品资料欢迎下载 - - -

41、- - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 12 页,共 17 页 - - - - - - - - - FileWriter fw = new FileWriter(manager.log, true); PrintWriter log = new PrintWriter(fw); log.println(-); log.println(this.getTeacherName(); /Student stu=(Student) o; log.println( 删除全部学生信息); log.println(=+new Date(0)+

42、=); log.flush(); log.close(); catch (IOException e) e.printStackTrace(); public void PieChart()/ 饼形图/ int count=scoreAna(); DefaultPieDataset pieDataset = new DefaultPieDataset(); int count = 0,0,0,0,0; / for() System.out.println( 输入课程名 ); Course o = new Course(); Scanner sc = new Scanner(System.in)

43、; String ss=sc.next(); o.setCourseNameValue(ss); / long sum=0; for(int i=0;ithis.studentList.size();i+) Student tempStu=(Student) this.studentList.get(i); int temp=(int) tempStu.getStudentCourseGrade(o); if(0=temp& temp60) count0+;/ 不及格人数 if(60=temp& temp70) count1+;/ 及格人数 if(70=temp& temp80) count2

44、+;/ 中等人数 if(80=temp& temp=100) 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 13 页,共 17 页 - - - - - - - - - count3+;/ 良好人数 if(90=tempStu.getStudentCourseGrade(o)& tempStu.getStudentCourseGrade(o)=100) count4+;/ 优秀人数 / for(int j=0;jcount.length;j+) / System.out.printl

45、n(countj); / pieDataset.setValue(优秀 ,count0); pieDataset.setValue(良好 ,count1); pieDataset.setValue(中等 ,count2); pieDataset.setValue(及格 ,count3); pieDataset.setValue(不及格 ,count4); JFreeChart chart = ChartFactory.createPieChart3D( 饼形图 ,pieDataset, true, false, false); /*A start*/ /设置标题字体样式chart.getTit

46、le().setFont(new Font( 黑体 ,Font.BOLD,20); /设置饼状图里描述字体样式PiePlot piePlot= (PiePlot) chart.getPlot(); piePlot.setLabelFont(new Font( 黑体 ,Font.BOLD,10); /设置显示百分比样式piePlot.setLabelGenerator(new StandardPieSectionLabelGenerator( (0(2), NumberFormat.getNumberInstance(), new DecimalFormat(0.00%); /设置统计图背景pi

47、ePlot.setBackgroundPaint(Color.white); /设置图片最底部字体样式chart.getLegend().setItemFont(new Font( 黑体 ,Font.BOLD,10); /*A end*/ try ChartUtilities.writeChartAsPNG(new FileOutputStream(pieChart.jpg), chart, 400, 300); catch (FileNotFoundException e) e.printStackTrace(); catch (IOException e) e.printStackTrac

48、e(); final ChartFrame preview = new ChartFrame(学生成绩情况 ,chart); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 14 页,共 17 页 - - - - - - - - - preview.pack(); preview.setVisible(true); / LabelFramePieChart app = new LabelFramePieChart(); / app.setDefaultCloseOperation(J

49、Frame.EXIT_ON_CLOSE); / app.setSize( 450,350 ); /app.setVisible( true ); -import java.io.*; import java.util.Arrays; import java.util.LinkedList; import java.util.List; import java.util.Scanner; import javax.swing.text.html.HTMLDocument.Iterator; public class Running public void start() throws IOExc

50、eption Teacher objTeacher=new Teacher(); Running run=new Running(); try ObjectInputStream is = new ObjectInputStream(new FileInputStream(TestObjectIO.txt); LinkedList tempList = (LinkedList) is.readObject();/ 从流中读取List 的数据objTeacher.setStudentList(LinkedList) tempList); Object stuArray=tempList.toAr

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 教育专区 > 高考资料

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知淘文阁网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号© 2020-2023 www.taowenge.com 淘文阁