簡單的學生成績管理系統java
1. 求一份簡單的java學生成績管理系統
你郵箱多少 我發給你。注意郵箱中間加幾個漢字不然會被屏蔽掉的
2. 急求!!一個java程序編寫的簡單的學生信息管理系統
僅僅給你個參考
//Java Group Project_StudentManagement源碼
//NetBeans IDE 6.5 環境
package studentmanager;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.*;
class Student implements java.io.Serializable{
String number,name,specialty,grade,borth,sex;
public Student(){};
public void setNumber(String number){ this.number=number;}
public String getNumber(){ return number;}
public void setName(String name){ this.name=name;}
public String getName(){ return name;}
public void setSex(String sex){ this.sex=sex;}
public String getSex(){ return sex;}
public void setSpecialty(String specialty){ this.specialty=specialty;}
public String getSpecialty(){ return specialty;}
public void setGrade(String grade){ this.grade=grade;}
public String getGrade(){ return grade;}
public void setBorth(String borth){ this.borth=borth;}
public String getBorth(){ return borth;}
}
public class StudentManager extends JFrame{
JLabel lb=new JLabel("錄入請先輸入記錄,查詢、刪除請先輸入學號,修改是對查詢" +
"內容改後的保存!");
JTextField 學號,姓名,專業,年級,出生;
JRadioButton 男,女;
ButtonGroup group=null;
JButton 錄入,查詢,刪除,修改,顯示;
JPanel p1,p2,p3,p4,p5,p6,pv,ph;
Student 學生=null;
Hashtable 學生散列表=null;
File file=null;
FileInputStream inOne=null;
ObjectInputStream inTwo=null;
FileOutputStream outOne=null;
ObjectOutputStream outTwo=null;
public StudentManager(){
super("學生基本信息管理系統");
學號=new JTextField(10);
姓名=new JTextField(10);
專業=new JTextField(10);
年級=new JTextField(10);
出生=new JTextField(10);
group=new ButtonGroup();
男=new JRadioButton("男",true);
女=new JRadioButton("女",false);
group.add(男);
group.add(女);
錄入=new JButton("錄入");
查詢=new JButton("查詢");
刪除=new JButton("刪除");
修改=new JButton("修改");
顯示=new JButton("顯示");
錄入.addActionListener(new InputAct());
查詢.addActionListener(new InquestAct());
修改.addActionListener(new ModifyAct());
刪除.addActionListener(new DeleteAct());
顯示.addActionListener(new ShowAct());
修改.setEnabled(false);
p1=new JPanel();
p1.add(new JLabel("學號:",JLabel.CENTER));
p1.add(學號);
p2=new JPanel();
p2.add(new JLabel("姓名:",JLabel.CENTER));
p2.add(姓名);
p3=new JPanel();
p3.add(new JLabel("性別:",JLabel.CENTER));
p3.add(男);
p3.add(女);
p4=new JPanel();
p4.add(new JLabel("專業:",JLabel.CENTER));
p4.add(專業);
p5=new JPanel();
p5.add(new JLabel("年級:",JLabel.CENTER));
p5.add(年級);
p6=new JPanel();
p6.add(new JLabel("出生:",JLabel.CENTER));
p6.add(出生);
pv=new JPanel();
pv.setLayout(new GridLayout(6,1));
pv.add(p1);
pv.add(p2);
pv.add(p3);
pv.add(p4);
pv.add(p5);
pv.add(p6);
ph=new JPanel();
ph.add(錄入);
ph.add(查詢);
ph.add(修改);
ph.add(刪除);
ph.add(顯示);
file=new File("學生信息.txt");
學生散列表=new Hashtable();
if(!file.exists()){
try{
FileOutputStream out=new FileOutputStream(file);
ObjectOutputStream objectOut=new ObjectOutputStream(out);
objectOut.writeObject(學生散列表);
objectOut.close();
out.close();
}
catch(IOException e){}
}
Container con=getContentPane();
con.setLayout(new BorderLayout());
con.add(lb, BorderLayout.NORTH);
con.add(pv, BorderLayout.CENTER);
con.add(ph, BorderLayout.SOUTH);
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(100,100,600,300);
setVisible(true);
}
public static void main(String[] args) {new StudentManager();}
class InputAct implements ActionListener{
public void actionPerformed(ActionEvent e){
修改.setEnabled(false);
String number="";
number=學號.getText();
if(number.length()>0){
try{
inOne=new FileInputStream(file);
inTwo=new ObjectInputStream(inOne);
學生散列表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exception ee){System.out.println("創建散列表出現問題!");}
if(學生散列表.containsKey(number)){
String warning="該生信息已存在,請到修改頁面修改!";
JOptionPane.showMessageDialog(null,warning,"警告",
JOptionPane.WARNING_MESSAGE);
}//end if1
else{
String m="該生信息將被錄入!";
int ok=JOptionPane.showConfirmDialog(null,m,"確認",
JOptionPane.YES_NO_OPTION,JOptionPane.INFORMATION_MESSAGE);
if(ok==JOptionPane.YES_OPTION){
String name=姓名.getText();
String specialty=專業.getText();
String grade=年級.getText();
String borth=出生.getText();
String sex=null;
if(男.isSelected()){sex=男.getText();}
else{sex=女.getText();}
學生=new Student();
學生.setNumber(number);
學生.setName(name);
學生.setSpecialty(specialty);
學生.setGrade(grade);
學生.setBorth(borth);
學生.setSex(sex);
try{
outOne=new FileOutputStream(file);
outTwo=new ObjectOutputStream(outOne);
學生散列表.put(number,學生);
outTwo.writeObject(學生散列表);
outTwo.close();
outOne.close();
}
catch(Exception ee){System.out.println("輸出散列表出現問題!");}
學號.setText(null);
姓名.setText(null);
專業.setText(null);
年級.setText(null);
出生.setText(null);
}
}//end else1
}//end if0
else{
String warning="必須輸入學號!";
JOptionPane.showMessageDialog(null,warning,
"警告",JOptionPane.WARNING_MESSAGE);
}//end else0
}//end actionPerformed
}//end class
class InquestAct implements ActionListener{
public void actionPerformed(ActionEvent e){
String number="";
number=學號.getText();
if(number.length()>0){
try{
inOne=new FileInputStream(file);
inTwo=new ObjectInputStream(inOne);
學生散列表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exception ee){System.out.println("散列表有問題!");}
if(學生散列表.containsKey(number)){
修改.setEnabled(true);
Student stu=(Student)學生散列表.get(number);
姓名.setText(stu.getName());
專業.setText(stu.getSpecialty());
年級.setText(stu.getGrade());
出生.setText(stu.getBorth());
if(stu.getSex().equals("男")){男.setSelected(true);}
else{女.setSelected(true);}
}
else{
修改.setEnabled(false);
String warning="該學號不存在!";
JOptionPane.showMessageDialog(null,warning,
"警告",JOptionPane.WARNING_MESSAGE);
}
}
else{
修改.setEnabled(false);
String warning="必須輸入學號!";
JOptionPane.showMessageDialog(null,warning,
"警告",JOptionPane.WARNING_MESSAGE);
}
}
}
class ModifyAct implements ActionListener{
public void actionPerformed(ActionEvent e){
String number=學號.getText();
String name=姓名.getText();
String specialty=專業.getText();
String grade=年級.getText();
String borth=出生.getText();
String sex=null;
if(男.isSelected()){sex=男.getText();}
else{sex=女.getText();}
Student 學生=new Student();
學生.setNumber(number);
學生.setName(name);
學生.setSpecialty(specialty);
學生.setGrade(grade);
學生.setBorth(borth);
學生.setSex(sex);
try{
outOne=new FileOutputStream(file);
outTwo=new ObjectOutputStream(outOne);
學生散列表.put(number, 學生);
outTwo.writeObject(學生散列表);
outTwo.close();
outOne.close();
學號.setText(null);
姓名.setText(null);
專業.setText(null);
年級.setText(null);
出生.setText(null);
}
catch(Exception ee){
System.out.println("錄入修改出現異常!");
修改.setEnabled(false);
}
}
}
class DeleteAct implements ActionListener{
public void actionPerformed(ActionEvent e){
修改.setEnabled(false);
String number=學號.getText();
if(number.length()>0){
try{
inOne=new FileInputStream(file);
inTwo=new ObjectInputStream(inOne);
學生散列表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exception ee){}
if(學生散列表.containsKey(number)){
Student stu=(Student)學生散列表.get(number);
姓名.setText(stu.getName());
專業.setText(stu.getSpecialty());
年級.setText(stu.getGrade());
出生.setText(stu.getBorth());
if(stu.getSex().equals("男")){男.setSelected(true);}
else{女.setSelected(true);}
}
String m="確定要刪除該學生的記錄嗎?";
int ok=JOptionPane.showConfirmDialog(null,m,"確認",
JOptionPane.YES_NO_OPTION,JOptionPane.QUESTION_MESSAGE);
if(ok==JOptionPane.YES_OPTION){
學生散列表.remove(number);
try{
outOne=new FileOutputStream(file);
outTwo=new ObjectOutputStream(outOne);
outTwo.writeObject(學生散列表);
outTwo.close();
outOne.close();
學號.setText(null);
姓名.setText(null);
專業.setText(null);
年級.setText(null);
出生.setText(null);
}
catch(Exception ee){System.out.println(ee);}
}
else if(ok==JOptionPane.NO_OPTION){
學號.setText(null);
姓名.setText(null);
專業.setText(null);
年級.setText(null);
出生.setText(null);
}
else{
String warning="該學號不存在!";
JOptionPane.showMessageDialog(null,warning,
"警告",JOptionPane.WARNING_MESSAGE);
}
}
else{
String warning="必須輸入學號!";
JOptionPane.showMessageDialog(null,warning,
"警告",JOptionPane.WARNING_MESSAGE);
}
}
}
class ShowAct implements ActionListener{
public void actionPerformed(ActionEvent e){
new StudentShow(file);
}
}
class StudentShow extends JDialog{
Hashtable 學生散列表= null;
JTextArea 顯示=null;
FileInputStream inOne=null;
ObjectInputStream inTwo=null;
File file=null;
public StudentShow(File file){
super(new JFrame(),"顯示對話框");
this.file=file;
顯示=new JTextArea(16,30);
try{
inOne=new FileInputStream(file);
inTwo=new ObjectInputStream(inOne);
學生散列表=(Hashtable)inTwo.readObject();
inOne.close();
inTwo.close();
}
catch(Exception ee){}
if(學生散列表.isEmpty())顯示.append("目前還沒有學生的信息記錄!\n");
else{
顯示.setText("學號 姓名 性別 專業 年級 出生\n");
for(Enumeration enm=學生散列表.elements();enm.hasMoreElements();){
Student stu=(Student)enm.nextElement();
String sex="";
if(stu.getSex().equals("男"))sex="男";
else sex="女";
String str=stu.getNumber()+","+stu.getName()+","+sex+","
+stu.getSpecialty()+","+stu.getGrade()+","+stu.getBorth()+"\n";
顯示.append(str);
}
}
JScrollPane scroll=new JScrollPane(顯示);
Container con=getContentPane();
con.add("Center",scroll);
con.validate();
setVisible(true);
setBounds(200,200,400,300);
addWindowListener(new WindowAdapter(){
public void windowClosing(WindowEvent e){setVisible(false);}
}
);
}
}
}
3. 簡單的java學生信息管理系統
package bean; public class Student { String name; String studentId; String sex; int grade; public Student(String name,String studentId,String sex,int grade){ this.name= name; this.studentId= studentId; this.sex = sex; this.grade = grade; } public int getGrade(){ return grade; } public String getName(){ return name; } public String getSex(){ return sex; } public void setGrade(int g){ this.grade = g; } public String getStudentId(){ return studentId; } }
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("***************"); System.out.println("您想選擇的操作是:");
import java.util.*;
Scanner sc = new Scanner(System.in); int choice = sc.nextInt();
package test; import java.util.*; import bean.Student; public class Manager { static List<Student> StudentList = new LinkedList<Student>(); public static void main(String[] agrs){ select(StudentList); } private static void select(List<Student> StudentList ){ 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("***************"); System.out.println("您想選擇的操作是:"); Scanner sc = new Scanner(System.in); int choice = sc.nextInt(); switch(choice){ //增加學生 case 1: System.out.print("請輸入學生的姓名:"); Scanner Sname = new Scanner(System.in); String name = Sname.nextLine(); System.out.print("請輸入學生的性別:"); Scanner Ssex = new Scanner(System.in); String sex = Ssex.nextLine(); System.out.print("請輸入學生的學號:"); Scanner SId = new Scanner(System.in); String studentId = SId.nextLine(); System.out.print("請輸入學生的成績:"); Scanner Sgrade = new Scanner(System.in); int grade = Sgrade.nextInt(); StudentList.add(new Student(name,studentId,sex,grade)); System.out.println("添加成功!!!!!"); select(StudentList); break; //刪除學生成績 case 2: System.out.print("請告訴我需要刪除學生的學號:"); Scanner Sid = new Scanner(System.in); String SstudentId = Sid.nextLine(); boolean isfindDelete = false; for (int i = 0; i < StudentList.size(); i++) { if(SstudentId.equals(StudentList.get(i).getStudentId())){ System.out.println("發現了該學生,正在刪除..."); StudentList.remove(i); System.out.println("刪除成功!!!"); isfindDelete =true; } } if(!isfindDelete){ System.out.println("抱歉,沒有找到"); } select(StudentList); break; //修改學生成績 case 3: System.out.print("請告訴我需要修改成績學生的學號:"); Scanner GId = new Scanner(System.in); String GstudentId = GId.nextLine(); boolean isfindChange = false; for (int j = 0; j < StudentList.size(); j++) { if(GstudentId.equals(StudentList.get(j).getStudentId())){ System.out.println("發現了該學生,正在修改..."); System.out.println("學生原成績為"+StudentList.get(j).getGrade()); System.out.print("請輸入修改後學生的成績:"); Scanner Ggrade = new Scanner(System.in); int grade2 = Ggrade.nextInt(); StudentList.get(j).setGrade(grade2); System.out.println("修改成功!!!"); isfindChange =true; }else{ } } if(!isfindChange){ System.out.println("抱歉,沒有找到"); } select(StudentList); break; //查看學生成績 case 4: System.out.print("請告訴我需要查詢學生的學號:"); Scanner CId = new Scanner(System.in); String CstudentId = CId.nextLine(); boolean isfindData = false; for (int i = 0; i < StudentList.size(); i++) { if(CstudentId.equals(StudentList.get(i).getStudentId())){ System.out.println("名字:"+StudentList.get(i).getName()); System.out.println("性別:"+StudentList.get(i).getSex()); System.out.println("學號:"+StudentList.get(i).getStudentId()); System.out.println("成績:"+StudentList.get(i).getGrade()); isfindData = true; } } if(!isfindData){ System.out.println("抱歉,沒有找到"); } select(StudentList); break; default: System.out.println("您輸入的數字有誤,請重新輸入:"); break; } } }
4. 用java編寫一個簡單的學生成績管理系統需要什麼知識點呢,是不是一定要用到資料庫呢
Swing會就OK了,資料庫可要可不要,因為你可以把數據寫死再程序裡面,當然用資料庫比較方便點
5. 求一個java做的簡單點的學生成績管理系統
你聯系方式
6. 求用Java編寫的學生成績管理系統的完整代碼
packagejdbcproj;
importjava.sql.*;
importjava.awt.BorderLayout;
importjava.awt.EventQueue;
importjavax.swing.JFrame;
importjavax.swing.JPanel;
importjavax.swing.border.EmptyBorder;
importjavax.swing.JLabel;
importjavax.swing.JOptionPane;
importjavax.swing.JTextField;
importjavax.swing.JButton;
importjava.awt.event.ActionListener;
importjava.sql.Connection;
importjava.sql.PreparedStatement;
importjava.sql.SQLException;
importjava.awt.event.ActionEvent;
{
privateJPanelcontentPane;
privateJTextFieldtxtname;
privateJTextFieldtxtpassword;
/**
*Launchtheapplication.
*/
publicstaticvoidmain(String[]args){
.invokeLater(newRunnable(){
publicvoidrun(){
try{
MainFrameframe=newMainFrame();
frame.setVisible(true);
}catch(Exceptione){
e.printStackTrace();
}
}
});
}
/**
*Createtheframe.
*/
publicMainFrame(){
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100,100,661,399);
contentPane=newJPanel();
contentPane.setBorder(newEmptyBorder(5,5,5,5));
setContentPane(contentPane);
contentPane.setLayout(null);
JLabellblNewLabel=newJLabel("u7528u6237u540D");
lblNewLabel.setBounds(114,51,72,18);
contentPane.add(lblNewLabel);
JLabellblNewLabel_1=newJLabel("u5BC6u7801");
lblNewLabel_1.setBounds(114,106,72,18);
contentPane.add(lblNewLabel_1);
txtname=newJTextField();
txtname.setBounds(261,48,86,24);
contentPane.add(txtname);
txtname.setColumns(10);
txtpassword=newJTextField();
txtpassword.setBounds(261,103,86,24);
contentPane.add(txtpassword);
txtpassword.setColumns(10);
JButtonbtnadd=newJButton("u589Eu52A0");
btnadd.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.addUser(u);
}
}
});
btnadd.setBounds(45,205,113,27);
contentPane.add(btnadd);
JButtonbtndelete=newJButton("u5220u9664");
btndelete.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEventarg0){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
UserDAOusdo=newUserDAO();
usdo.delUser(txtname.getText());;
}
}
});
btndelete.setBounds(172,205,113,27);
contentPane.add(btndelete);
JButtonbtnupdate=newJButton("u4FEEu6539");
btnupdate.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals("")||txtpassword.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名和密碼不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
u.setPwd(txtpassword.getText());
u.setUsername(txtname.getText());
UserDAOusdo=newUserDAO();
usdo.updateUser(u);;
}
}
});
btnupdate.setBounds(300,205,113,27);
contentPane.add(btnupdate);
JButtonbtnfind=newJButton("u67E5u8BE2");
btnfind.addActionListener(newActionListener(){
publicvoidactionPerformed(ActionEvente){
if(txtname.getText().equals(""))
{
JOptionPane.showMessageDialog(getContentPane(),"用戶名不能為空","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
Usersu=newUsers();
UserDAOusdo=newUserDAO();
u=usdo.findUser(txtname.getText(),txtpassword.getText());
if(u!=null){
JOptionPane.showMessageDialog(getContentPane(),"該用戶存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
else{
JOptionPane.showMessageDialog(getContentPane(),"該用戶不存在!","提示信息框",JOptionPane.WARNING_MESSAGE);
}
}
}
});
btnfind.setBounds(427,205,113,27);
contentPane.add(btnfind);
//記得要寫這個
setVisible(true);
}
}
7. 求用Java編寫的學生成績管理系統的完整代碼,要能運行的
以下方法實現了用戶界面登陸
import java.awt.*;
import java.awt.event.*;
public class DengLuJieMian extends Frame implements ActionListener
{
Label username=new Label("用戶名:");//使用文本創建一個用戶名標簽
TextField t1=new TextField();//創建一個文本框對象
Label password=new Label("密碼:");//創建一個密碼標簽
TextField t2=new TextField();
Button b1=new Button("登陸");//創建登陸按鈕
Button b2=new Button("取消");//創建取消按鈕
public DengLuJieMian()
{
this.setTitle("學生信息管理系統");//設置窗口標題
this.setLayout(null);//設置窗口布局管理器
username.setBounds(50,40,60,20);//設置姓名標簽的初始位置
this.add(username);// 將姓名標簽組件添加到容器
t1.setBounds(120,40,80,20);// 設置文本框的初始位置
this.add(t1);// 將文本框組件添加到容器
password.setBounds(50,100,60,20);//密碼標簽的初始位置
this.add(password);//將密碼標簽組件添加到容器
t2.setBounds(120,100,80,20);//設置密碼標簽的初始位置
this.add(t2);//將密碼標簽組件添加到容器
b1.setBounds(50,150,60,20);//設置登陸按鈕的初始位置
this.add(b1);//將登陸按鈕組件添加到容器
b2.setBounds(120,150,60,20);//設置取消按鈕的初始位置
this.add(b2);// 將取消按鈕組件添加到容器
b1.addActionListener(this);//給登陸按鈕添加監聽器
b2.addActionListener(this);// 給取消按鈕添加監聽器
this.setVisible(true);//設置窗口的可見性
this.setSize(300,200);//設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
});//通過內部類重寫關閉窗體的方法
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==b1)//處理登陸事件
{
String name=t1.getText();
String pass=t2.getText();
if(name!=null&&pass.equals("000123"))//判斷語句
{
new StudentJieMian();
}
}
}
public static void main(String args[])//主函數
{
new DengLuJieMian();
}
}
以下方法實現了學生界面設計
import java.awt.*;
import java.awt.event.*;
class StudentJieMian extends Frame implements ActionListener
{
MenuBar m=new MenuBar();//創建菜單欄
Menu m1=new Menu("信息");//創建菜單「信息」
MenuItem m11=new MenuItem("插入");//創建「插入」的菜單項
MenuItem m12=new MenuItem("查詢");
Menu m2=new Menu("成績");//創建菜單「成績」
MenuItem m21=new MenuItem("查詢");
public StudentJieMian()
{
this.setTitle("學生界面");//設置窗口標題
this.setLayout(new CardLayout());//設置窗口布局管理器
this.setMenuBar(m);//將菜單欄組件添加到容器
m.add(m1);//將信息菜單放入菜單欄
m.add(m2);
m1.add(m11);//將「插入」菜單項添加到「信息」菜單
m1.add(m12); //將「查詢」菜單項添加到「信息」菜單
m2.add(m21); //將「查詢」菜單項添加到「成績」菜單
m11.addActionListener(this); //給「插入」菜單項添加監聽器
m12.addActionListener(this); //給「查詢」菜單項添加監聽器
m21.addActionListener(this); //給「查詢」菜單項添加監聽器
this.setVisible(true); //設置窗口的可見性
this.setSize(300,200); //設置窗口的大小
addWindowListener(new WindowAdapter()
{
public void windowClosing(WindowEvent e)
{
System.exit(0);//關閉窗口
}
});
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource()==m11) //處理「添加信息」事件
{
new AddStudent();
}
if(e.getSource()==m12) //處理「查詢信息」事件
{
new SelectStudent();
}
if(e.getSource()==m21) //處理「查詢成績」事件
{
new ChengJiStudent();
}
}
public static void main(String args[])
{ new StudentJieMian(); //創建一個對象 }
8. Java實現學生簡易信息管理系統
importjava.util.*;
importjava.io.*;
classStuMgr{
publicstaticclassStudent{
;
publicStringname;
publicintage;
publicStudent(intid,Stringname,intage){
this.id=id;
this.name=name;
this.age=age;
}
@Override
publicStringtoString(){
returnid+","+name+","+age;
}
}
publicList<Student>stuList=newLinkedList<>();
publicvoidadd(){
Scannersc=newScanner(System.in);
System.out.println("請輸入學生學號:");
Stringid=sc.nextLine();
intintId=0;
try{
intId=Integer.parseInt(id);
}catch(NumberFormatExceptionex){
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(NumberFormatExceptionex){
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(NumberFormatExceptionex){
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(NumberFormatExceptionex){
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;
BufferedWriterwriter=null;
try{
fw=newFileWriter(file);
writer=newBufferedWriter(fw);
while(iterator.hasNext()){
writer.write(iterator.next().toString());
writer.newLine();//換行
}
writer.flush();
}catch(FileNotFoundExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finally{
try{
writer.close();
fw.close();
}catch(IOExceptione){
e.printStackTrace();
}
}
}
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方法沒實現,留給你自己練手。
9. 學生成績管理系統 java
這個在網上是賣錢的喲。我手頭也沒有現成的。
你可以去網上下個差不多的,大致修改一下就可以了。
10. Java實現一個簡單的學生信息管理系統
看了你的需求,其實除了java,你還可以用易查分來做查詢管理系統呢!通過易查分 不用寫代碼,上 傳個excel表格就可以生成,超級簡單的!