今天给各位分享学员管理系统java代码的知识,其中也会对学生管理系统java源码进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!
本文目录一览:
1、怎么用java做一个简单的学生管理系统?2、用Java 实现一个简单的学生管理系统! 求代码,求代码!!!!3、Java实现学生简易信息管理系统4、给我一个详细的学生管理系统,用java做的5、简单的JAVA学生管理系统代码···
怎么用java做一个简单的学生管理系统?
用java写的话,可以用List来实现学生管理系统:\x0d\x0a首先,管理系统是针对学生对象的,所以我们先把学生对象就写出来:\x0d\x0apackage bean;\x0d\x0apublic class Student {\x0d\x0a String name;\x0d\x0a String studentId;\x0d\x0a String sex;\x0d\x0a int grade;\x0d\x0a public Student(String name,String studentId,String sex,int grade){\x0d\x0a this.name= name;\x0d\x0a this.studentId= studentId;\x0d\x0a this.sex = sex;\x0d\x0a this.grade = grade; \x0d\x0a }\x0d\x0a public int getGrade(){\x0d\x0a return grade;\x0d\x0a }\x0d\x0a public String getName(){\x0d\x0a return name;\x0d\x0a }\x0d\x0a public String getSex(){\x0d\x0a return sex;\x0d\x0a }\x0d\x0a public void setGrade(int g){\x0d\x0a this.grade = g;\x0d\x0a }\x0d\x0a public String getStudentId(){\x0d\x0a return studentId;\x0d\x0a }\x0d\x0a}\x0d\x0a这里面定义了一些得到当前学生对象数据的一些get方法,和成绩修改的set方法,代码很简单,就不做详细的解答。\x0d\x0a就下来就是我们的正文了。\x0d\x0a虽然我们暂时不用swing来做界面,但是总得要看的过去吧,所以,先做了一个比较简单的界面:\x0d\x0a System.out.println(“***************”);\x0d\x0a System.out.println(“*欢迎来到学生管理系统 *”);\x0d\x0a System.out.println(“*1:增加学生 *”);\x0d\x0a System.out.println(“*2:删除学生 *”);\x0d\x0a System.out.println(“*3:修改成绩 *”);\x0d\x0a System.out.println(“*4:查询成绩 *”);\x0d\x0a System.out.println(“***************”);\x0d\x0a System.out.println(“您想选择的操作是:”);\x0d\x0a这里可以看到,我们的是用一个1234来选择项目,说以不得不讲一下Java如何获取到键盘所输入的数据———Scanner ,要使用这个,首先需要import进来一个包:\x0d\x0a例如这里:\x0d\x0aimport java.util.*;\x0d\x0a之后的两行代码搞定输入:\x0d\x0aScanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt();\x0d\x0a接下来就是各个功能的实现:\x0d\x0a\x0d\x0apackage test;\x0d\x0aimport java.util.*;\x0d\x0aimport bean.Student;\x0d\x0apublic class Manager {\x0d\x0a static List StudentList = new LinkedList();\x0d\x0a public static void main(String[] agrs){\x0d\x0a select(StudentList); \x0d\x0a }\x0d\x0a private static void select(List StudentList ){\x0d\x0a System.out.println(“***************”);\x0d\x0a System.out.println(“*欢迎来到学生管理系统 *”);\x0d\x0a System.out.println(“*1:增加学生 *”);\x0d\x0a System.out.println(“*2:删除学生 *”);\x0d\x0a System.out.println(“*3:修改成绩 *”);\x0d\x0a System.out.println(“*4:查询成绩 *”);\x0d\x0a System.out.println(“***************”);\x0d\x0a System.out.println(“您想选择的操作是:”);\x0d\x0a Scanner sc = new Scanner(System.in);\x0d\x0a int choice = sc.nextInt(); \x0d\x0a switch(choice){\x0d\x0a //增加学生\x0d\x0a case 1:\x0d\x0a System.out.print(“请输入学生的姓名:”);\x0d\x0a Scanner Sname = new Scanner(System.in);\x0d\x0a String name = Sname.nextLine();\x0d\x0a System.out.print(“请输入学生的性别:”);\x0d\x0a Scanner Ssex = new Scanner(System.in);\x0d\x0a String sex = Ssex.nextLine();\x0d\x0a System.out.print(“请输入学生的学号:”);\x0d\x0a Scanner SId = new Scanner(System.in);\x0d\x0a String studentId = SId.nextLine();\x0d\x0a System.out.print(“请输入学生的成绩:”);\x0d\x0a Scanner Sgrade = new Scanner(System.in);\x0d\x0a int grade = Sgrade.nextInt();\x0d\x0a StudentList.add(new Student(name,studentId,sex,grade));\x0d\x0a System.out.println(“添加成功!!!!!”);\x0d\x0a select(StudentList);\x0d\x0a break;\x0d\x0a //删除学生成绩\x0d\x0a case 2:\x0d\x0a System.out.print(“请告诉我需要删除学生的学号:”);\x0d\x0a Scanner Sid = new Scanner(System.in);\x0d\x0a String SstudentId = Sid.nextLine();\x0d\x0a boolean isfindDelete = false;\x0d\x0a for (int i = 0; i
回答于 2022-11-16
用Java 实现一个简单的学生管理系统! 求代码,求代码!!!!
完成了,希望能帮到你
刚开始会叫你输入编号选择功能
import java.io.*;
public class student {
public static void main(String args[]) throws IOException{
int[] stud = {77,99,55,46,82,75,65,31,74,85};
System.out.println(“请选择功能:”);//输入编号选择功能
System.out.println(“1、输入学号,查询该学生成绩:”);
System.out.println(“2、输入成绩,查询学生学号:”);
System.out.println(“3、输入学号,删除该学生成绩”);
System.out.println(“请选择编号:”);
BufferedReader td = new BufferedReader(new InputStreamReader(System.in));
String temp = td.readLine();
int choice = Integer.valueOf(temp);
if(choice == 1){//一为查询学生成绩
System.out.println(“请输入学号:”);
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
System.out.print(“学号为 “+No+” 的学生成绩为: ” + stud[No-1] +”分”);
}
if(choice == 2){//二为查询学生编号
System.out.println(“请输入成绩:”);
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String chengji = sd.readLine();
int temp_cj = Integer.valueOf(chengji);
for(int i=0;istud.length;i++){
if(temp_cj == stud[i]){
System.out.print(“成绩为 “+ temp_cj+ “的学生的学号为: “+(i+1));
}
}
}
if(choice == 3){//三为删除操作
System.out.println(“请输入学号:”);
BufferedReader sd = new BufferedReader(new InputStreamReader(System.in));
String temp_sd = sd.readLine();
int No = Integer.valueOf(temp_sd);
stud[No-1]=0;//直接赋值为0,不删除学生
System.out.print(“学号为 “+No+” 的学生成绩为: ” + stud[No-1] +”分”);
}
}
}
Java实现学生简易信息管理系统
import java.util.*;
import java.io.*;
class StuMgr{
public static class Student{
public int id;
public String name;
public int age;
public Student(int id ,String name,int age){
this.id = id;
this.name = name;
this.age = age;
}
@Override
public String toString(){
return id + “,” + name + “,” + age;
}
}
public ListStudent stuList = new LinkedList();
public void add(){
Scanner sc = new Scanner(System.in);
System.out.println(“请输入学生学号:”);
String id = sc.nextLine();
int intId = 0;
try{
intId = Integer.parseInt(id);
}catch(NumberFormatException ex){
System.out.println(“学号输入有误,请输入数字!”);
return;
}
if (find(intId) != null){
System.out.println(“该学号已经存在!”);
return ;
}
System.out.println(“请输入学生姓名:”);
String name = sc.nextLine();
System.out.println(“请输入学生年龄:”);
String age = sc.nextLine();
int intAge = 0;
try{
intAge = Integer.parseInt(age);
}catch(NumberFormatException ex){
System.out.println(“年龄输入有误,请输入数字!”);
return;
}
Student stu = new Student(intId,name,intAge);
stuList.add(stu);
store();
System.out.println(“———————–“);
System.out.println(“学生信息已增加”);
System.out.println(stu);
System.out.println(“———————–“);
}
public void del(){
Scanner sc = new Scanner(System.in);
System.out.println(“请输入学生学号:”);
String id = sc.nextLine();
int intId = 0;
try{
intId = Integer.parseInt(id);
}catch(NumberFormatException ex){
System.out.println(“学号输入有误,请输入数字!”);
return;
}
Student stu = 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(“———————–“);
}
public void find(){
Scanner sc = new Scanner(System.in);
System.out.println(“请输入学生学号:”);
String id = sc.nextLine();
int intId = 0;
try{
intId = Integer.parseInt(id);
}catch(NumberFormatException ex){
System.out.println(“学号输入有误,请输入数字!”);
return;
}
Student stu = find(intId);
if ( stu == null){
System.out.println(“该学号不存在!”);
return ;
}
System.out.println(“———————–“);
System.out.println(“查找学生信息如下”);
System.out.println(stu);
System.out.println(“———————–“);
}
public Student find(int id){
for(Student stu : stuList){
if(stu.id == id){
return stu;
}
}
return null;
}
public void modify(){
store();
}
public void foreach(){
System.out.println(“———————–“);
for(Student stu : stuList){
System.out.println(stu);
}
System.out.println(“———————–“);
}
public void store(){
Iterator iterator = stuList.iterator();
File file = new File(“stuList.txt”);
FileWriter fw = null;
BufferedWriter writer = null;
try {
fw = new FileWriter(file);
writer = new BufferedWriter(fw);
while(iterator.hasNext()){
writer.write(iterator.next().toString());
writer.newLine();//换行
}
writer.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
}catch (IOException e) {
e.printStackTrace();
}finally{
try {
writer.close();
fw.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public static void main(String[] args){
StuMgr mgr = new StuMgr();
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(“———————–“);
Scanner sc = new Scanner(System.in);
String op = 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方法没实现,留给你自己练手。
给我一个详细的学生管理系统,用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);}
}
);
}
}
}
简单的JAVA学生管理系统代码···
lListStudent students = new ArrayListStudent();
BufferedReader br = new BufferedReader(new FileReader(“D:\student.txt”));
String tmpStr = br.readLine();
while(tmpStr != null){
int firstIndex = tmpStr.indexOf(” “);
int secondIndex = tmpStr.indexOf(” “,firstIndex + 1);
int thirdIndex = tmpStr.indexOf(” “, secondIndex + 1);
int forthIndex = tmpStr.indexOf(” “, thirdIndex + 1);
Integer stuId = Integer.parseInt(tmpStr.substring(0,firstIndex));
String stuName = tmpStr.substring(firstIndex + 1,secondIndex);
Integer stuYW = Integer.parseInt(tmpStr.substring(secondIndex + 1,thirdIndex));
Integer stuSX = Integer.parseInt(tmpStr.substring(thirdIndex + 1,forthIndex));
Integer stuYY = Integer.parseInt(tmpStr.substring(forthIndex + 1));
Student student = new Student();
student.setStuId(stuId);
student.setStuName(stuName);
student.setStuYW(stuYW);
student.setStuSX(stuSX);
student.setStuYY(stuYY);
students.add(student);
tmpStr.readLine();
}
//创建一个学生实体类 封装stuId stuName stuYW stuSx stuYY 这5个属性。。。
//已经帮你把数据拆分出来 并以Student 对象的形式放入集合中了 接下来 给分吧 哇咔咔
学员管理系统java代码的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于学生管理系统java源码、学员管理系统java代码的信息别忘了在本站进行查找喔。