学生考勤系统.doc_第1页
学生考勤系统.doc_第2页
学生考勤系统.doc_第3页
学生考勤系统.doc_第4页
学生考勤系统.doc_第5页
已阅读5页,还剩13页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

软 件 学 院课程设计报告书课程名称 Java EE课程设计 设计题目 学生考勤系统 专业班级 学 号 姓 名 指导教师 2011年12月目录1 设计时间32 设计目的33设计任务34 设计内容34.1 程序流程图34.1.1主菜单模块设计54.1.2录入学生信息64.1.3删除学生信息74.1.4输出学生信息84.2调试问题,调试记录及解决94.3附录:系统源代码95 总结与展望16参考文献17成绩评定171 设计时间2011.12.202 设计目的用户以合法身份登录系统后,才能进行所有操作;用户可以添加、查看和删除学生考勤信息(学号、姓名、班级、出勤状态);出勤状态有两种:出勤和旷课;考勤结束后,如果学生旷课次数超过考勤次数的1/3, 系统提示用户该学生没有考试资格。3设计任务(1)添加学生考勤信息(2)查看学生考勤信息(3)删除学生考勤信息(4)统计无考试资格学生:给出没有考试资格的学生的学号和姓名4 设计内容 4.1 程序流程图 图1 流程图 图2 E-R图数据库表: 表1 考勤表 表2 学生情况表4.1.1主菜单模块设计 图2 信息4.1.2录入学生信息 图3 登陆4.1.3删除学生信息 图4 删除4.1.4输出学生信息 图4 输出4.2调试问题,调试记录及解决1 取出的数据有误,采用了判断消息是否有效的方式解决。2 JTextArea 与 JScrollPane 结合后bounds的设置,发现只要设置JScrollPane即可。3 JFileChooser对象只能选择文件,通过网络上搜索知道了可以设置JFileChooser.FILES_AND_DIRECTORIES 就可以实现同时可以选定文件夹和文件。4.3附录:系统源代码class Mycompare implements java.util.Comparator public int compare(Object o1, Object o2) Student a1 = (Student) o1; Student a2 = (Student) o2; return a1.scorea2.score?1:-1; public class StudentString Sname;int Time;double score;public Student(String name)Sname=name;Time=1;score=100;import java.awt.Color;import java.awt.event.*;import java.io.*;import java.util.*;import javax.swing.*;public class StudentAttendStatistics extends JFrame private JTextArea jta;private static int stucount=0;private JFileChooser fileChooser;private File dir,save;private Student stu;private int N;public StudentAttendStatistics() throws Exceptionthis.setTitle(考勤情况统计系统);fileChooser=new JFileChooser();fileChooser.setCurrentDirectory(new File(.);/设置当前目录fileChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES );/设置 JFileChooser,以允许用户只选择文件、只选择目录,或者可选择文件和目录。this.setBounds(400,100,500 ,650);this.setLayout(null);/设置布局JLabel jla=new JLabel(请输入你要统计文件所在的文件夹);jla.setBounds(0, 0, 200, 20);this.add(jla);JButton jb=new JButton(浏览);jb.setBounds(200,0,150,20);jb.addActionListener(new ActionListener()public void actionPerformed(ActionEvent event) try int res=fileChooser.showOpenDialog(null);/弹出一个 Open File 文件选择器对话框。 if (res = JFileChooser.APPROVE_OPTION)/选择确认(yes、ok)后返回该值。 dir=new File(fileChooser.getSelectedFile().getPath();/返回选中的文件,将此抽象路径名转换为一个路径名字符串。 stu=new Student1000; String str; str=dir.list();/返回由此抽象路径名所表示的目录中的文件和目录的名称所组成字符串数组。 N=str.length;/需要统计的文件的个数 /System.out.println(N); for(int i=0;istr.length;+i) File F=new File(dir,stri); /System.out.println(F.toString(); BufferedReader br=new BufferedReader(new FileReader(F); String line; while(br.ready()/判断此流是否已准备好被读取。如果缓冲区不为空,或者基础字符流已准备就绪,则缓冲的字符流准备就绪。 line=br.readLine();/读取一个文本行。 StringTokenizer record=new StringTokenizer(line,);/字符串分词器 if (record.countTokens()=3) /选择有效记录 record.nextToken(); String name=record.nextToken(); int j; for(j=0;jstucount;+j) if (stuj.Sname.equals(name) stuj.Time+; break; if (j=stucount) stustucount+=new Student(name); /System.out.println(name); br.close(); catch(Exception e) e.printStackTrace(); );this.add(jb);JLabel jla1=new JLabel(保存路径设定);jla1.setBounds(0,25,200,20);this.add(jla1);JButton jb1=new JButton(浏览);jb1.setBounds(200,25,150,20);jb1.addActionListener(new ActionListener()public void actionPerformed(ActionEvent event) try int res=fileChooser.showSaveDialog(null); if (res=fileChooser.APPROVE_OPTION) String path=fileChooser.getSelectedFile().getPath(); if (path.indexOf(.txt)=-1) path+=.txt; save=new File(path); catch(Exception e) e.printStackTrace(); );this.add(jb1);JButton jb2=new JButton(统计);jb2.setBounds(400,0,100,20);jb2.addActionListener(new ActionListener()public void actionPerformed(ActionEvent event)try for(int i=0;istucount;+i) stui.score=(stui.Time)/(double)N)*100; Arrays.sort(stu,0,stucount,new Mycompare(); /File savepath=new File(save,考勤统计情况.txt); PrintWriter pw=new PrintWriter(new BufferedWriter(new FileWriter(save);/向文本输出流打印对象的格式化表示形式。 java.text.DecimalFormat df=new java.text.DecimalFormat(0.00); pw.println(考勤统计情况:); for(int i=0;istucount;+i) /System.out.println(t姓名:+stui.Sname+t出勤次数:+stui.Time+t缺勤次数: +(N-stui.Time)+t出勤分数:+df.format(stui.score); jta.append(姓名:+stui.Sname+t出勤次数:+stui.Time+t缺勤次数: +(N-stui.Time)+t出勤分数:+df.format(stui.score)+n); pw.println(姓名:+stui.Sname+t出勤次数:+stui.Time+t缺勤次数: +(N-stui.Time)+t出勤分数:+df.format(stui.score); pw.close();catch(Exception e)e.printStackTrace(););this.add(jb2);JButton jb3=new JButton(退出);jb3.setBounds(400,25,100,20);jb3.addActionListener(new ActionListener()public void actionPerformed(ActionEvent event)System.exit(0););this.add(jb3);JLabel Res=new JLabel(考勤情况统计结果:);Res.setBounds(0,80,200,20);this.add(Res);jta=new JTextArea();jta.setEditable(false);jta.setBackground(Color.BLACK);jta.setForeground(Color.WHITE);this.add(jta);JScrollPane jsp=new JScrollPane(jta);jsp.setBounds(5,100,475,500);this.add(jsp); this.setVisible(true);public static void main(String args) throws Exception/ TODO Auto-generated method stub new StudentAttendStatistics();5 总结与展望完成了这个课题设计,同时我感觉自己的系统设计道路才刚刚起步。前方还有更多的任务等着我去完成。系统设计对我来说还是比较陌生的,在未来的日子里我一定会一点点的进步。该系统现在时能完成老师对考勤情况统计的要求。而经过修改后就能完成更多的统计任务。相信使用得当能给我的学习生活带来便利。参考文献1 屈辉立,陈可明,石武信.JSP网站编程教程M.第1版, 北京:北京希望电子出版社,2005 2 白勇.用B/S模式构建在线考试系统J,重庆电力高等专科学校学报,2003,10(4): 100130. 3

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论