




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、.课 程 设 计 说 明 书设计题目: 学生成绩管理系统 专 业: 软件工程 班级: 设 计 人: 2010年 6 月 18 日*;大学学生课程设计一、软件的功能描述主界面: (1) 信息整理1.录入信息本模块实现录入学生学号、姓名以及各科成绩的功能。并实现了几个完整性约束的判断。点击“下一条”,进入下一条学生信息的录入;点击“取消”,则取消当前的录入操作。当输入格式不正确时:当存储的文件里已有该信息时:2. 修改信息本模块实现对学生信息的修改功能。点击“下一条”,进入下一条学生信息的修改;点击“取消”,则取消当前的修改操作。当修改符合要求时:当输入格式不正确时:当输入的学号不存在时:3. 删
2、除信息本模块实现对学生信息的删除功能。输入要删除的学号,点击“确定”,实现删除;点击“取消”,则取消当前操作。当删除成功时:当输入学号格式不正确时:当记录中没有该信息时:(2) 成绩管理1. 平均成绩数据库平均成绩:2. 成绩降序数据库成绩降序排列(以表格形式输出):(3) 综合评估1. 柱状图数据结构成绩柱状图(标识属性名称和数量): 2. 饼形图 Java成绩饼形图(标识属性和百分比): (4) 查询1. 学生成绩查询 输入学号,以表格形式输出信息 当输入格式不正确时:若输入的学号不存在时:2. 班级成绩查询以表格形式输入整个班级信息情况,以学号升序排列: 二、系统的UML类图图 学生成绩
3、管理UML类图三、系统实现的核心代码第13页1.package StudentManagement;public class StudentManagementTest public static void main(String args)new Management();2.package StudentManagement;import javax.swing.*;import java.awt.*;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.io.*;public
4、class Management extends JFrameprivate static final long serialVersionUID = 1L;JPanel j=new JPanel();private JMenuBar menuBar=new JMenuBar();private JLabel label=new JLabel("请选择一个菜单项");private JMenu menu1=new JMenu("信息整理");private JMenu menu2=new JMenu("成绩管理");private J
5、Menu menu3=new JMenu("综合评估");private JMenu menu4=new JMenu("查询"); private JMenuItem insert=new JMenuItem("插入"); private JMenuItem alter=new JMenuItem("修改"); private JMenuItem delete=new JMenuItem("删除"); private JMenu aver=new JMenu("平均成绩");
6、 private JMenu desc=new JMenu("成绩降序"); private JMenuItem averDB=new JMenuItem("数据库成绩"); private JMenuItem averJava=new JMenuItem("Java成绩"); private JMenuItem averDS=new JMenuItem("数据结构成绩"); private JMenuItem descDB=new JMenuItem("数据库成绩"); private JMe
7、nuItem descJava=new JMenuItem("Java成绩"); private JMenuItem descDS=new JMenuItem("数据结构成绩"); private JMenu volumn=new JMenu("柱状图"); private JMenuItem DBVolumn=new JMenuItem("数据库成绩"); private JMenuItem JavaVolumn=new JMenuItem("Java成绩"); private JMenuIt
8、em DSVolumn=new JMenuItem("数据结构成绩"); private JMenu cake=new JMenu("饼状图"); private JMenuItem DBCake=new JMenuItem("数据库成绩"); private JMenuItem JavaCake=new JMenuItem("Java成绩"); private JMenuItem DSCake=new JMenuItem("数据结构成绩"); private JMenuItem show=ne
9、w JMenuItem("学生成绩查询"); private JMenuItem showAll=new JMenuItem("班级成绩查询"); private Image img=null; Container container=null; public Management() super("成绩管理系统"); container=this.getContentPane(); desc.add(descDB); desc.add(descJava); desc.add(descDS); aver.add(averDB); av
10、er.add(averJava); aver.add(averDS); volumn.add(DBVolumn); volumn.add(JavaVolumn); volumn.add(DSVolumn); cake.add(DBCake); cake.add(JavaCake); cake.add(DSCake); menu1.add(insert); menu1.add(alter); menu1.add(delete); menu2.add(aver); menu2.add(desc); menu3.add(volumn); menu3.add(cake); menu4.add(show
11、); menu4.add(showAll); menuBar.add(menu1); menuBar.add(menu2); menuBar.add(menu3); menuBar.add(menu4); container.add(j); this.setJMenuBar(menuBar); /插入图片 JPanel jp = new JPanel() private static final long serialVersionUID = 1L;public void paintComponent(Graphics g) super.paintComponent(g); img =new
12、ImageIcon("管理.jpg").getImage(); g.drawImage(img,0,0,this); ; jp.add(label); this.add(jp); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); init();/初始化主界面 /插入、修改界面 final JFrame insertFrame=new JFrame("学生信息");insertFrame.setLayout(null);JLabel noLabel =new JLabel("学号"
13、);JLabel nameLabel=new JLabel("姓名"); JLabel DBLabel =new JLabel("数据库成绩"); JLabel javaLabel=new JLabel("java成绩"); JLabel DSLabel=new JLabel("数据结构"); JButton next=new JButton("下一条"); JButton back=new JButton("返回"); final JButton ok=new JButto
14、n("录入"); final JButton alterButton=new JButton("修改"); final JTextField noField =new JTextField(); final JTextField nameField =new JTextField(); final JTextField DBField =new JTextField(); final JTextField javaField =new JTextField(); final JTextField DSField =new JTextField(); fi
15、nal JLabel oklabel=new JLabel(); noLabel.setBounds(10, 20, 100, 25); nameLabel.setBounds(10,80,100,25); DBLabel.setBounds(10,140,100,25); javaLabel.setBounds(10,200,100,25); DSLabel.setBounds(10,260,100,25); noField.setBounds(100,20,200,25); nameField.setBounds(100,80,200,25); DBField.setBounds(100,
16、140,200,25); javaField.setBounds(100,200,200,25); DSField.setBounds(100,260,200,25);alterButton.setBounds(350,50,80,25);ok.setBounds(350,50,80,25);next.setBounds(350, 120, 80, 25);back.setBounds(350, 190, 80, 25); oklabel.setForeground(Color.RED);oklabel.setBounds(80,140,200,50); insertFrame.add(okl
17、abel);insertFrame.add(noLabel);insertFrame.add(nameLabel);insertFrame.add(DBLabel);insertFrame.add(javaLabel);insertFrame.add(DSLabel);insertFrame.add(noField);insertFrame.add(nameField);insertFrame.add(DBField);insertFrame.add(javaField);insertFrame.add(DSField);insertFrame.add(next);insertFrame.ad
18、d(back); insertFrame.setBounds(200, 150, 500, 400);insertFrame.setResizable(false); /录入功能 insert.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) alterButton.setVisible(false);ok.setVisible(true);insertFrame.add(ok);noField.setText("");nameField.setText(&quo
19、t;");DBField.setText("");javaField.setText("");DSField.setText("");insertFrame.setVisible(true););next.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) noField.setText(""); nameField.setText(""); DBField.setText(&
20、quot;"); javaField.setText(""); DSField.setText(""); oklabel.setVisible(false); );ok.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) int flag=0; try BufferedReader brStu = new BufferedReader(new FileReader("E:/Student.txt"); String
21、str=null;while(str=brStu.readLine()!=null)if(str.split("t")0.equals(noField.getText()flag=1; catch (IOException e2) e2.printStackTrace(); if(noField.getText().equals("") |flag=1|nameField.getText().equals("")|DBField.getText().equals("")|javaField.getText().eq
22、uals("")|DSField.getText().equals("")|isLong(noField.getText()=false|isDouble(DBField.getText()=false|isDouble(javaField.getText()=false|isDouble(DSField.getText()=false) if(flag=1) JOptionPane.showMessageDialog(null,"已有该信息!","错误",JOptionPane.WARNING_MESSAGE);
23、 else JOptionPane.showMessageDialog(null,"请重新输入学生信息!","错误",JOptionPane.WARNING_MESSAGE);noField.setText(""); nameField.setText(""); DBField.setText(""); javaField.setText(""); DSField.setText("");/if 判断是否有未输入的空白文本和 输入格式是否为double e
24、lse Student stu=new Student( noField.getText(), nameField.getText(), Double.parseDouble(DBField.getText(),Double.parseDouble(javaField.getText(), Double.parseDouble(DSField.getText(); try int count; BufferedReader br = newBufferedReader(new FileReader("E:/count.txt");count=Integer.parseInt
25、(br.readLine(); BufferedWriter bw = new BufferedWriter(new FileWriter("E:/count.txt");bw.write(""+(+count); bw.flush(); bw.close(); br.close();/记录学生个数 BufferedWriter bwStu = new BufferedWriter(new FileWriter("E:/Student.txt",true);bwStu.write(stu.getNo()+"t"+s
26、tu.getName()+"t" +stu.getDatabase()+"t"+stu.getJava()+"t"+stu.getDS();bwStu.newLine();bwStu.flush();bwStu.close();oklabel.setVisible(true);oklabel.setFont(new Font("",1,36);oklabel.setText("录入成功!"); catch (IOException e1) e1.printStackTrace(); ); bac
27、k.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) insertFrame.setVisible(false);); /修改功能alter.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) ok.setVisible(false);alterButton.setVisible(true);insertFrame.add( alterButton);oklabel.setV
28、isible(false);noField.setText(""); nameField.setText(""); DBField.setText(""); javaField.setText(""); DSField.setText("");insertFrame.setVisible(true); ); alterButton.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) if
29、(noField.getText().equals("")|nameField.getText().equals("") |DBField.getText().equals("") |javaField.getText().equals("") |DSField.getText().equals("") |isLong(noField.getText()=false|isDouble(DBField.getText()=false|isDouble(javaField.getText()=fal
30、se|isDouble(DSField.getText()=false)JOptionPane.showMessageDialog(null,"请重新输入学生信息!", "错误",JOptionPane.WARNING_MESSAGE);noField.setText("");nameField.setText("");DBField.setText("");javaField.setText("");DSField.setText("");/if 判断是
31、否有未输入的空白文本和 输入格式是否为doubleelseStudent stu=new Student(noField.getText(),nameField.getText(), Double.parseDouble(DBField.getText(), Double.parseDouble(javaField.getText(), Double.parseDouble(DSField.getText();try BufferedWriter bwTempStu =new BufferedWriter(new FileWriter("E:/temp.txt");Buff
32、eredReader brStu = new BufferedReader(new FileReader("E:/Student.txt"); String str=null; int flag=0;while(str=brStu.readLine()!=null) if(str.split("t")0.equals(stu.getNo()bwTempStu.write(stu.getNo()+"t"+stu.getName()+"t" +stu.getJava()+"t"+stu.getDat
33、abase() +"t"+stu.getDS();flag=1;else bwTempStu.write(str);bwTempStu.newLine();bwTempStu.flush();bwTempStu.close();brStu.close();BufferedReader brTempStu = new BufferedReader(new FileReader("E:/temp.txt");BufferedWriter bwStu = new BufferedWriter(new FileWriter("E:/Student.tx
34、t");while(str=brTempStu.readLine()!=null) bwStu.write(str);bwStu.newLine();brTempStu.close();bwStu.flush();bwStu.close();if(flag=1)JOptionPane.showMessageDialog(null,"修改成功","提示信息",JOptionPane.INFORMATION_MESSAGE);elseJOptionPane.showMessageDialog(null,"没有该信息,修改失败",
35、"提示信息",JOptionPane.INFORMATION_MESSAGE);noField.setText(""); nameField.setText(""); DBField.setText(""); javaField.setText(""); DSField.setText("");catch (IOException e1)e1.printStackTrace(); );/删除功能delete.addActionListener( new ActionListe
36、ner()public void actionPerformed(ActionEvent e) new Delete(); ); /查询功能show.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) new Search(); );showAll.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) new Desc(0); );/平均成绩averDB.addActionLis
37、tener(new ActionListener()public void actionPerformed(ActionEvent e) tryBufferedReader brStu = new BufferedReader(new FileReader("E:/Student.txt");getAver(brStu,2);brStu.close();catch(IOException e1)e1.printStackTrace(); );averJava.addActionListener(new ActionListener()public void actionPe
38、rformed(ActionEvent e) tryBufferedReader brStu = new BufferedReader(new FileReader("E:/Student.txt");getAver(brStu,3);brStu.close();catch(IOException e1) e1.printStackTrace(); );averDS.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) try BufferedReader brStu
39、 = new BufferedReader(new FileReader("E:/Student.txt");getAver(brStu,4); brStu.close();catch(IOException e1) e1.printStackTrace(););/成绩降序/采用冒泡排序 然后记录数组下标 再让学生对象重新排列 descDB.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) new Desc(1););descJava.addActionListe
40、ner(new ActionListener()public void actionPerformed(ActionEvent e) new Desc(2););descDS.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) new Desc(3); ); /柱状图 DBVolumn.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) try BufferedReader b
41、r = new BufferedReader(new FileReader("E:/Student.txt");int a=getArray(br,2);br.close();volumnTest volumn=new volumnTest(a); volumn.setTitle("数据库成绩柱状图"); volumn.setVisible(true); volumn.setResizable(false);catch(IOException e1)e1.printStackTrace(););JavaVolumn.addActionListener(n
42、ew ActionListener()public void actionPerformed(ActionEvent e) tryBufferedReader br = new BufferedReader(new FileReader("E:/Student.txt");int a=getArray(br,3);br.close();volumnTest volumn=new volumnTest(a); volumn.setTitle("Java成绩柱状图"); volumn.setVisible(true);volumn.setResizable(
43、false);catch(IOException e1)e1.printStackTrace(); );DSVolumn.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) try BufferedReader br = new BufferedReader(new FileReader("E:/Student.txt");int a=getArray(br,4);br.close();volumnTest volumn=new volumnTest(a);volu
44、mn.setTitle("数据结构成绩柱状图");volumn.setVisible(true);volumn.setResizable(false);catch(IOException e1)e1.printStackTrace(); );DBCake.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) try BufferedReader br = new BufferedReader(new FileReader("E:/Student.txt&qu
45、ot;);int a=getArray(br,2);br.close(); floatsum=a0+a1+a2+a3+a4;CakyPlan cakyplan = new CakyPlan();cakyplan.setTitle("数据库成绩饼形图");cakyplan.setVisible(true); cakyplan.setAlwaysOnTop(true); CakyPlan.jPanel.insert("优秀", a0/sum*100); CakyPlan.jPanel.insert("良好", a1/sum*100); C
46、akyPlan.jPanel.insert("中等", a2/sum*100); CakyPlan.jPanel.insert("及格", a3/sum*100); CakyPlan.jPanel.insert("不及格",a4/sum*100); cakyplan.setResizable(false);catch(IOException e1)e1.printStackTrace(); );JavaCake.addActionListener(new ActionListener()public void actionPerfor
47、med(ActionEvent e) try BufferedReader br = new BufferedReader(new FileReader("E:/Student.txt");int a=getArray(br,3);br.close();float sum=a0+a1+a2+a3+a4;CakyPlan cakyplan = new CakyPlan();cakyplan.setTitle("Java成绩饼形图"); cakyplan.setVisible(true); cakyplan.setAlwaysOnTop(true);Caky
48、Plan.jPanel.insert("优秀", a0/sum*100); CakyPlan.jPanel.insert("良好", a1/sum*100);CakyPlan.jPanel.insert("中等", a2/sum*100); CakyPlan.jPanel.insert("及格", a3/sum*100); CakyPlan.jPanel.insert("不及格",a4/sum*100); cakyplan.setResizable(false);catch(IOExceptio
49、n e1)e1.printStackTrace(); );DSCake.addActionListener(new ActionListener()public void actionPerformed(ActionEvent e) try BufferedReader br = new BufferedReader(new FileReader("E:/Student.txt");int a=getArray(br,4);br.close();float sum=a0+a1+a2+a3+a4;CakyPlan cakyplan = new CakyPlan(); caky
50、plan.setTitle("数据结构成绩饼形图"); cakyplan.setVisible(true); cakyplan.setAlwaysOnTop(true); CakyPlan.jPanel.insert("优秀", a0/sum*100); CakyPlan.jPanel.insert("良好", a1/sum*100); CakyPlan.jPanel.insert("中等", a2/sum*100); CakyPlan.jPanel.insert("及格", a3/sum*10
51、0); CakyPlan.jPanel.insert("不及格",a4/sum*100); cakyplan.setResizable(false);catch(IOException e1) e1.printStackTrace(); );private boolean isDouble(String num) try Double.parseDouble(num); return true;catch ( NumberFormatException e ) return false; private boolean isLong(String num) try Long
52、.parseLong(num); return true; catch ( NumberFormatException e ) return false; private int getArray(BufferedReader br,int index) int a=new int5; try String str=null; while(str=br.readLine()!=null) if(Double.parseDouble(str.split("t")index)>=90) a0+; else if(Double.parseDouble(str.split(&
53、quot;t")index)>=80) a1+; else if(Double.parseDouble(str.split("t")index)>=70) a2+; else if(Double.parseDouble(str.split("t")index)>=60) a3+; else a4+; catch(IOException e) e.printStackTrace(); return a;private void getAver(BufferedReader br,int index) String str=nul
54、l;double sum=0;int count=0; try while(str=br.readLine()!=null) sum=sum+Double.parseDouble(str.split("t")index);count+;if(index=2)JOptionPane.showMessageDialog(null,"数据库平均成绩:t"+Math.round(sum/count*100)/100.0,"平均成绩",JOptionPane.INFORMATION_MESSAGE);else if(index=3)JOptionPane.showMessageDialog(null,"Java平均成绩:t"+Math.round(sum/count*100)/100.0,"平均成绩",JOptionPane.INFORMATION_MESSAGE);else JOptionPane.showMessageDialog(null,"数据结构平均成绩:t"+Math.round(sum/count*100)/100.0,&qu
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 污水装置安装合同协议书
- 父母商铺过户协议书模板
- 物业与业主协议合同范本
- 消防维保终止合同协议书
- 股权回收合同协议书范本
- 闲置玻璃钢改造合同范本
- 申请廉租房劳务合同范本
- 浙江商会合作合同协议书
- 物流运输调车协议书范本
- 游乐场地板采购合同协议
- 成都辅警考试题库及答案
- 健康讲座:血管通路维护与管理
- 2025年国企中层干部竞聘笔试题含答案
- 公司文化培训课件模板
- 2024华中科技大学辅导员招聘笔试真题
- 五年级英语上册单词表(完整版)人教版
- 食堂从业人员食品安全知识考试题及答案
- 2024年中国烟草招聘历年面试真题部分含答案解析
- 2025即时零售全时段消费新场景趋势洞察
- 2025年北京市中考数学试卷真题
- 2025年浙江6月高考地理真题(原卷版)
评论
0/150
提交评论