教學管理系統java
A. 如何用java製作學生管理系統
是要小型的還是大型的 小型的 需要資料庫嗎?下面這是個 控制台輸出的
importjava.util.List;
importjava.util.Scanner;
importcn.com.shxt.DBUtils.JdbcTool;
publicclassStudentManager{
/*
1.學生信息管理系統,界面如下
1--學生信息添加
2--全部學生信息查詢
3--查詢錄取學生的信息
4--按學號查詢錄取學生的信息
5--按姓名查詢錄取學生的信息
6--退出
*/
publicstaticvoidmain(String[]args){
Scannerscan=newScanner(System.in);
JdbcTooljt=newJdbcTool();
List<List<String>>tableList;
intflag;
Stringno;
Stringname;
Stringmain;
Stringpolitics;
StringEnglish;
StringMath;
StringMajor;
StringTotal;
Stringsql;
booleanpanan=true;
while(panan){
System.out.println();
System.out.println("===========歡迎進入研究生錄取系統================");
System.out.println("1--學生信息添加");
System.out.println("2--錄入學生信息查詢");
System.out.println("3--查詢錄取學生的信息");
System.out.println("4--按學號查詢錄取學生的信息");
System.out.println("5--按姓名查詢錄取學生的信息");
System.out.println("0--退出");
System.out.println("請輸入序號,選擇功能");
flag=scan.nextInt();
switch(flag){
case1:
System.out.println("請輸入學生的學號、姓名、報考專業、政治、英語、高數、專業課分數");
no=scan.next();
name=scan.next();
main=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
inttotal=0;
total=Integer.parseInt(politics)+Integer.parseInt(English)+Integer.parseInt(Math)+Integer.parseInt(Major);
sql="insertintostumanager(s_no,s_name,s_main,s_politics,s_English,s_Math,s_Major,s_Total)values('"+no+"','"+name+"','"+main+"',"+politics+",'"+English+"','"+Math+"','"+Major+"','"+total+"')";
jt.update(sql);
System.out.println("添加成功");
break;
case2:
sql="select*fromstumanagerorderbys_totaldesc";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
}
}else{
System.out.println("沒有學生信息,請添加~~");
break;
}
break;
case3:
System.out.println("請輸入報考專業以及政治、英語、高數、專業課、總分的分數");
main=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
sql="select*fromstumanagerwheres_main='"+main+"'ands_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"";
tableList=jt.query(sql);
if(tableList.size()!=0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case4:
System.out.println("請輸入要查詢的學生的學號以及政治、英語、高數、專業課、總分的錄取分數");
no=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
System.out.println("此學生的信息:");
sql="select*fromstumanagerwheres_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"ands_no="+no+"";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case5:
System.out.println("請輸入要查詢的學生姓名(單個文字也可)以及政治、英語、高數、專業課、總分的錄取分數");
name=scan.next();
politics=scan.next();
English=scan.next();
Math=scan.next();
Major=scan.next();
Total=scan.next();
sql="select*fromstumanagerwheres_politics>="+politics+"ands_English>="+English+"ands_Math>="+Math+"ands_Major>="+Major+"ands_Total>="+Total+"ands_namelike'%"+name+"%'";
tableList=jt.query(sql);
if(tableList!=null&&tableList.size()>0){
tableList=jt.query(sql);
for(List<String>rowList:tableList){
System.out.println("id 學號 姓名 專業 政治 英語 高數 專業 總分 ");
System.out.println(rowList.get(0)+" "+rowList.get(1)+" "+rowList.get(2)+" "+rowList.get(3)+" "+rowList.get(4)+" "+rowList.get(5)+" "+rowList.get(6)+" "+rowList.get(7)+" "+rowList.get(8));
System.out.println("恭喜你,你被錄取了");
}
}else{
System.out.println("抱歉,你沒有被錄取");
break;
}
break;
case0:
panan=false;
break;
}
}
}
}
B. 怎麼用java做一個簡單的學生管理系統
用java寫的話,可以用List來實現學生管理系統:x0dx0a首先,管理系統尺孫是針對學生對象的,所以我們先把學生對象就寫出來:x0dx0apackage bean;x0dx0apublic class Student {x0dx0a String name;x0dx0a String studentId;x0dx0a String sex;x0dx0a int grade;x0dx0a public Student(String name,String studentId,String sex,int grade){x0dx0a this.name= name;x0dx0a this.studentId= studentId;x0dx0a this.sex = sex;x0dx0a this.grade = grade; x0dx0a }x0dx0a public int getGrade(){x0dx0a return grade;x0dx0a }x0dx0a public String getName(){x0dx0a return name;x0dx0a }x0dx0a public String getSex(){x0dx0a return sex;x0dx0a }x0dx0a public void setGrade(int g){x0dx0a this.grade = g;x0dx0a }x0dx0a public String getStudentId(){x0dx0a return studentId;x0dx0a }x0dx0a}x0dx0a這裡面定義了一些得到當前學生對象數據的一些get方法,和成績修改的set方法,代碼很簡單,就不做詳細的解答。x0dx0a就下來就是我們的正文了。x0dx0a雖然我們暫時不用swing來做界面,但是總得要看的過去吧,所以,先做了一個比較簡單的界面:x0dx0a System.out.println("***************");x0dx0a System.out.println("*歡迎來到學生管理系統 *");x0dx0a System.out.println("*1:增加學生脊搜 *");x0dx0a System.out.println("*2:刪除學生 *");x0dx0a System.out.println("*3:修改成績 *");x0dx0a System.out.println("*4:查詢成績 *");x0dx0a System.out.println("***************");x0dx0a System.out.println("您想選擇的操作是:");x0dx0a這里可以看到,我們的是用一個1234來選擇項目,說以不得不講一下Java如何獲取到鍵盤所輸入的數據---------Scanner ,要使用這個,首先需要import進來一個包:x0dx0a例如這里:x0dx0aimport java.util.*;x0dx0a之後的兩行代碼搞定輸入:x0dx0aScanner sc = new Scanner(System.in);x0dx0a int choice = sc.nextInt();x0dx0a接下來就是各個功能的陵野鏈實現:x0dx0ax0dx0apackage test;x0dx0aimport java.util.*;x0dx0aimport bean.Student;x0dx0apublic class Manager {x0dx0a static List
C. Java實現學生簡易信息管理系統(java學生信息管理系統設計)
importjava.util.*;
importjava.io.*;
classStuMgr{
publicstaticclassStudent{
publicintid;
publicStringname;
publicintage;
publicStudent(intid,Stringname,intage){
this.id=id;
this.name=name;
this.age=age;
}
@Override
publicStringtoString(){
returnid","name","age;
}
}
publicList
publicvoidadd(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(ex){
System.out.println("學號輸入有誤,請輸入數字!");
return;
}
if(find(intId)!=null){
System.out.println("該學號已經存在!");
return;
}
System.out.println("請輸入學生姓名:");
Stringname=sc.nextLine();
System.out.println("請輸入學生年齡:");
Stringage=sc.nextLine();
intintAge=0;
try{
intAge=Integer.parseInt(age);
}catch(ex){
System.out.println("年齡輸入有誤,請輸入絕胡激數字!");
return;
}
Studentstu=newStudent(intId,name,intAge);
stuList.add(stu);
store();
System.out.println("-----------------------");
System.out.println("學生信息已增加");
System.out.println(stu);
System.out.println("-----------------------");
}
publicvoiddel(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(ex){
System.out.println("學號輸入有誤,請輸入數字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("該學號不存在!");
return;
}
stuList.remove(stu);
store();
System.out.println("-----------------------");
System.out.println("學生信息已刪除");
System.out.println(stu);
System.out.println("-----------------------");
}
publicvoidfind(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:做棗");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(ex){
System.out.println("學號輸入有誤並襪,請輸入數字!");
return;
}
Studentstu=find(intId);
if(stu==null){
System.out.println("該學號不存在!");
return;
}
System.out.println("-----------------------");
System.out.println("查找學生信息如下");
System.out.println(stu);
System.out.println("-----------------------");
}
publicStudentfind(intid){
for(Studentstu:stuList){
if(stu.id==id){
returnstu;
}
}
returnnull;
}
publicvoidmodify(){
store();
}
publicvoidforeach(){
System.out.println("-----------------------");
for(Studentstu:stuList){
System.out.println(stu);
}
System.out.println("-----------------------");
}
publicvoidstore(){
Iteratoriterator=stuList.iterator();
Filefile=newFile("stuList.txt");
FileWriterfw=null;
writer=null;
try{
fw=newFileWriter(file);
writer=new(fw);
while(iterator.hasNext()){
writer.write(iterator.next().toString());
writer.newLine();//換行
}
writer.flush();
}catch(e){
e.();
}catch(IOExceptione){
e.();
}finally{
try{
writer.close();
fw.close();
}catch(IOExceptione){
e.();
}
}
}
publicstaticvoidmain(String[]args){
StuMgrmgr=newStuMgr();
while(true){
System.out.println("請選擇您要進行的操作:");
System.out.println("1:增加學生信息");
System.out.println("2:刪除學生信息");
System.out.println("3:查找學生信息");
System.out.println("4:修改學生信息");
System.out.println("5:遍歷學生信息");
System.out.println("6:退出");
System.out.println("-----------------------");
Scannersc=newScanner(System.in);
Stringop=sc.nextLine();
if("6".equals(op)){
return;
}
if("1".equals(op)){
mgr.add();
}
if("2".equals(op)){
mgr.del();
}
if("3".equals(op)){
mgr.find();
}
if("4".equals(op)){
mgr.modify();
}
if("5".equals(op)){
mgr.foreach();
}
}
}
}
時間倉促,還有一個modify方法沒實現,留給你自己練手。