用java编写的学生成绩管理系统代码
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
//student
import java.sql.*;
public class Student
{
private 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)
{
= 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 Exception {
String 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 = "\n\n\t\t\t学生成绩\n\n\t\t 1 新增\n\t\t 2 更改\n\t\t 3 删除\n\t\t 4 查找\n\t\t 5 显示\n\t\t 0 退出\n\n";
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("JA V A:");
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("JA V A:");
java = Keyboard.getInteger();
System.out.println("计算机:");
computer = Keyboard.getInteger();
stmt.executeUpdate("update lxh1 set math='" + math + "',english='"