2023年-Java大作业学生成绩管理.docx
《2023年-Java大作业学生成绩管理.docx》由会员分享,可在线阅读,更多相关《2023年-Java大作业学生成绩管理.docx(30页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、本科学生综合性实验报告课程名称:Java开发技术项目名称:学生成绩管理系统学生姓名 学号指导教师开课学期 20n至2012学年第一学期完成时间 2011 年1月 3 日课程信息管理课 程 信 息 添 加课 程 信 息 修 改课 程 信 息 查 询课 程 信 息 删 除图3.5-课程信息管理模块成 绩 信 息 删 除成 绩 信 息 查 询成 绩 信 息 修 改成 绩 统 计成绩信息管理成绩信息添加图36成绩信息管理模块3.2学生成绩管理系统的功能模块简介:(1)基本信息管理(以学生为例)if (obj=tianj ia) /添力口(Sno=tf_xuehao.getText () .trim()
2、;Sname=tf_xingming.getText().trim();sex=tf_xingbie . getText() .trim();age1=1nteger.parseint(tf_nianling.getText().trim();tel_no=tf_dianhua.getText().trim();classno=tf_banhao.getText().trim();addr=tf_dizhi.getText () .trim();if(Sno length ()=0| |Sname.length()=0| |sex.length ()=0| |agel=0| | Sno len
3、gth() =0| |tel_no.length()=0| |addr.length()=0| |classno.length 0 =0)(JOptionPane . showMessageOia1og(this, ”请添力口完整信息!“,”提示 信息J , JOptionPane. QUESTION_MESSAGE);elsetryps=con.prepareStatement(ninsert into student values,?,?,?,?,?,?)”);Sno);Sname); sex); classno); addr);ps , setstring (1, ps , setstr
4、ing (2, ps , setstring (3, ps , setstring (4, ps , setstring (5,ps.setlnt (6, agel);ps.setstring (7, tel_no);JOptionPane . s匕owMessage。工a_Jog (this, ”确定添力口吗? “,”提 示信息“,JOptionPane. QUESTION_MESSAGE);tf_xuehao.setText();tf_xingming.setText( );tf_xingbie.setText(“);tf_nianling.setText();tf_dianhua.set
5、Text ( n);tf_dizhi . setText(n);tf_banhao.setText ( );rs=ps . executeQuery ();)catch(SQLException sql) (JOptionPane . sbowMessageDialog (t his添力口成功!,”提示信 息”,JOptionPane . QUESTION_MESSAGE);)if (obj=xiugai) /修改(String no=shuru.getText () .trim();Sno=tf_xuehao.getText().trim();Sname=tf_xingming.getTex
6、t().trim();sex=tf_xingbie . getText() .trim();age1=Integer.parseint(tf_nianling.getText().trim();tel_no=tf_dianhua.getText() .trim();addr=tf_dizhi.getText().trim();classno=tf_banhao.getText().trim();try(ps=con.prepareStatement(Hupdate student setSno=?,Sname=?,sex=?,classno=?,addr=?,age=?,tel_no=? wh
7、ere Sno=?H);ps . setstring(1, Sno);ps.setstring(2, Sname);ps.setString(3,sex);pssetstring (4,classno);ps.setstring (5,addr);ps . setlnt (6fagel);ps.setstring(7,tel_no);ps.setString(8,no);JOptionPane . s力owMessageOialog(this, ”确定修改吗?”提示信息”,JOptionPane . QUESTION_MESSAGE);tf_xuehao.setText(H;tf_xingmi
8、ng.setText(n);tf_xingbie . setText();tf_banhao.setText(H);tf_dizhi . setText();tf_nianling.setText(n);tf_dianhua.setText(n);JOptionPane . s匕owMessageDialog (this, ”修改成功! n,”提示信息”,JOptionPane . INFORMATION_MESSAGE);rs=ps . executeQuery(); rs , next ();)catch(SQLException sql) (JOptionPane.showMessage
9、Dialog(Component)null,sql.getMessage(), ”提 示信息“,JOptionPane . QUESTION_MESSAGE);)if (obj=shanchu) /删除(try(String no=shuru.getText().trim();ps=con.prepareStatement(delete from student where Sno=?n);ps . setstring(1,no);JOptionPane . showMessageOialog(this, ”确定册U除吗?”提示信 息”,JOptionPane.QUESTION_MESSAGE
10、);tf_xuehao.setText();tf_nianling.setText(n n);tf_xingming.setText(n);tf_dianhua.setText( );tf_dizhi . setText();tf_xingbie . setText();tf_banhao.setText();rs=ps . executeQuery();JOptionPane . showMessageOialog(this, ”册“除成功! ”,”提示信息 , JOptionPane . INFORMATION_MESSAGE);catch(SQLException sqlex) (sql
11、ex . getMessage(); )if (obj=qingkong) /清空 (shuru . setText (n);tf_xuehao.setText ( n);tf_nianling.setText( );tf_xingming.setText( );tf_dianhua.setText( );tf_dizhi . setText();tf_xingbie.setText( “);tf banhao.setText ();)主要功能:添加、删除、修改、查询学生基本信息。实现目的:对于每个新的学年都有大量的学生入录,对学生信息的添加是必不可少的。同时,在管 理员的日常工作过程中,难免
12、不出现错误。所以对其信息修改功能也是必不可少的,删除则 是在学生开除学籍时可以使用。同时课程、教师、成绩信息和学生信息操作是相同的。(2)成绩统计:/统计各科平均分public String SubjectAvg(String subject)String s = null;float t = 0 ;this , Connect ();if (subject .equals (计算机网络“) (s = select avg(grade) from transcript where Cno=003125n; try(st = this.Connect().prepareStatement(s);
13、rs = st.executeQuery();while(rs.next()(t = rs.getFloat (1);)catch(Exception e)e printStackTrace();)if (subject .equals (”数据库系统原理”) (s = select avg(grade) from transcript where Cno=003126H; try(st = this . Connect() .prepareStatement(s);rs = st.executeQuery();while(rs.next()(t = rs.getFloat (1);)catc
14、h(Exception e)e.printStackTrace ();if (subject. equals (多媒体技术基础”) (s = select avg(grade) from transcript where Cno=003127; try(st = this . Connect() .prepareStatement(s);rs = st.executeQuery();while(rs.next()t = rs.getFloat (1);catch(Exception e)e printStackTrace ();if (subject. equals (概率论与数理统计”)s
15、= select avg(grade) from transcript where Cno=003128; try(st = this . Connect() .prepareStatement(s);rs = st.executeQuery();while(rs.next()t = rs.getFloat (1);catch(Exception e)e printStackTrace();return Float.toString(t);/总分平均分统计public String allAvg()float sum = 0;int count = 0;st = this.Connect().
16、prepareStatement(sql);String s = select sum(grade) as total from transcript;System.out.printIn(”s=+s);tryst = this . Connect() .prepareStatement(s);rs = st.executeQuery ();System.out.printin(nrs=n+rs);if(rs.next ()(sum = rs.getFloat(total);System.out.printin(nsum=H+sum);)rs = null;s = select sum(gra
17、de) from transcript where Cno=001325n;st = this . Connect() .prepareStatement(s);rs = st.executeQuery ();if (rs.next ()(sum =sum + rs.getFloat(1);)rs = null;s = nselect sum(grade) from transcript where Cno=001326n;st = this . Connect() .prepareStatement(s);rs = st.executeQuery ();if(rs.next()(sum =s
18、um + rs.getFloat(1);)rs = null;s = select sum(grade) from transcript where Cno=001328n;st = this . Connect () .prepareStatement(s);rs = st.executeQuery ();if(rs.next ()(sum =sum + rs.getFloat(1);)rs = null;s = select count(distinct Sno) from transcript;st = this . Connect() .prepareStatement(s);rs =
19、 st.executeQuery ();if (rs.next ()(count = rs.getlnt(1);)catch(Exception e)e.printStackTrace ();)if(count = 0)return n 0 n;elsesum = sum/count;return Float.toString(sum);/获得各科的分数段人数public int gethigh(String subjectrint grade) /总的人数int num = 0;String s = null;this Connect();if (subject.equals (计算机网络”
20、)grade60grade70grade80grade=60 and a . Cno=b . Cno and Cname=计算机网络”; if(grade = 80)s = select count (sno) from transcript a,course b and grade =70 and a . Cno=b. Cno and Cnama=计算机网络”; if(grade = 90)s = nselect count (sno) from transcript a,course b and grade =80 and a . Cno=b. Cno and Cnam=计算机网络”; i
21、f(grade = 100)s = select count (sno) from transcript a,course bwherewherewherewherewheregrade=90 and a . Cno=b . Cno and Cname=计算机网络; tryst = this.Connect().prepareStatement(s);rs = st.executeQuery();while(rs.next()num= rs.getlnt (1);)catch(Exception e)e , printStackTrace ();)if (subject. equals (”数
22、据库系统原理”)if(grade = 60)s = select count (sno) from transcript a,course b where grade 60 and a . Cno=b . Cno and Cname=数据库系统原理”;if(grade = 70)s = select count (sno) from transcript a,course b where grade =60 and a . Cno=b . Cno and Cname=数据库系统原理”; if(grade = 80)s = select count (sno) from transcript a
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2023 Java 作业 学生 成绩 管理
限制150内