用java编写的学生成绩管理系统代码(共6页).doc
-
资源ID:13560098
资源大小:24KB
全文页数:6页
- 资源格式: DOC
下载积分:20金币
快捷下载
会员登录下载
微信登录下载
三方登录下载:
微信扫一扫登录
友情提示
2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
|
用java编写的学生成绩管理系统代码(共6页).doc
精选优质文档-倾情为你奉上/studentimport java.sql.*;public class Studentprivate String id;private String name;private int math;private int english;private int java;private int computer;public String getId()return id;public void setId(String id)this.id = id;public String getName()return name;public void setName(String name)this.name = name;public int getMath()return math;public void setMath(int math)this.math = math;public int getEnglish()return english;public void setEnglish(int english)this.english = english;public int getJava()return java;public void setJava(int java)this.java = java;public int getComputer()return computer;public void setComputer(int computer)puter = computer;public static void main(String args) throws ExceptionString id;String cid;String name;int math;int english;int java;int computer;String DBDriver = "sun.jdbc.odbc.JdbcOdbcDriver"String conStr = "jdbc:odbc:student"Connection con = null;Statement stmt = null;ResultSet rs = null;Class.forName(DBDriver);con = DriverManager.getConnection(conStr, "student", "123");stmt = con.createStatement();String s = "nnttt学 生 成 绩nntt 1 新 增ntt 2 更 改ntt 3 删 除ntt 4 查 找ntt 5 显 示ntt 0 退 出nn"System.out.print(s);int choice = Keyboard.getInteger();switch (choice)/ 添加学生case 1:System.out.print("请输入学生信息n");System.out.print("学号:");id = Keyboard.getString();System.out.print("姓名:");name = Keyboard.getString();System.out.print("数学:");math = Keyboard.getInteger();System.out.print("英语:");english = Keyboard.getInteger();System.out.print("JAVA:");java = Keyboard.getInteger();System.out.print("计算机:");computer = Keyboard.getInteger();stmt.executeUpdate("insert into lxh1 values('" + id + "','"+ name + "','" + math + "','" + english + "','" + java+ "','" + computer + "')");System.out.println("n添加完成。");break;/ 更改成绩case 2:System.out.println("请输入要改的学生学号:");cid = Keyboard.getString();System.out.println("数学:");math = Keyboard.getInteger();System.out.println("英语:");english = Keyboard.getInteger();System.out.println("JAVA:");java = Keyboard.getInteger();System.out.println("计算机:");computer = Keyboard.getInteger();stmt.executeUpdate("update lxh1 set math='" + math + "',english='"+ english + "',java='" + java + "',computer='" + computer+ "' where sno=" + cid + "");System.out.println("n修改完成");break;/ 删除指定学生case 3:System.out.println("请输入要改的学生学号:");cid = Keyboard.getString();stmt.executeUpdate("delete from lxh1 where sno=" + cid + "");System.out.println("n删除完成");break;/ 显示指定学生case 4:System.out.println("请输入查找的学生学号:");cid = Keyboard.getString();System.out.println("n" + cid+ "号学生信息nn学号t姓名t数学t英语tJAVAt计算机t");rs = stmt.executeQuery("select * from lxh1 where sno=" + cid+ "");while (rs.next()System.out.println(rs.getInt("sno") + "t"+ rs.getString("sname") + "t" + rs.getString("math")+ "t" + rs.getString("english") + "t"+ rs.getString("java") + "t"+ rs.getString("computer") + "t");break;case 5:/ 输出全部信息System.out.println("n全部学生信息nn学号t姓名t数学t英语tJAVAt计算机t平均成绩");rs = stmt.executeQuery("select * from lxh1 order by math desc");while (rs.next()int a = rs.getInt("math");int b = rs.getInt("english");int c = rs.getInt("java");int d = rs.getInt("computer");System.out.println(rs.getString("sno") + "t"+ rs.getString("sname") + "t" + a + "t" + b + "t"+ c + "t" + d + "t" + (a + b + c + d) / 4);/ 输出平均分System.out.println("n各科平均分nn数学t英语tJAVAt计算机t");rs = stmt.executeQuery("select avg(math),avg(english),avg(java),avg(computer) from lxh1");while (rs.next()System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"+ rs.getInt(3) + "t" + rs.getInt(4);/ 输出最高分System.out.println("n各科最高分nn数学t英语tJAVAt计算机t");rs = stmt.executeQuery("select max(math),max(english),max(java),max(computer) from lxh1");while (rs.next()System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"+ rs.getInt(3) + "t" + rs.getInt(4);/ 输出最低分System.out.println("n各科最低分nn数学t英语tJAVAt计算机t");rs = stmt.executeQuery("select min(math),min(english),min(java),min(computer) from lxh1");while (rs.next()System.out.println(rs.getInt(1) + "t" + rs.getInt(2) + "t"+ rs.getInt(3) + "t" + rs.getInt(4);break;case 0:break;default:System.out.println("感谢您的使用,再见!");stmt.close();con.close();专心-专注-专业