好文档就是一把金锄头!
欢迎来到金锄头文库![会员中心]
电子文档交易市场
安卓APP | ios版本
电子文档交易市场
安卓APP | ios版本

学生信息管理java.doc

4页
  • 卖家[上传人]:wm****3
  • 文档编号:42903982
  • 上传时间:2018-06-04
  • 文档格式:DOC
  • 文档大小:38.50KB
  • / 4 举报 版权申诉 马上下载
  • 文本预览
  • 下载提示
  • 常见问题
    • /*** AWT Sample application** @author * @version 1.00 12/05/06*/import javax.swing.*; import java.io.*; import java.awt.*; import java.awt.event.*; import java.util.*;public class Unit {public static void main(String[] args) {Vector stuList=new Vector();String stu=““,line=““,input=““,name=““;boolean flag=true; int value,age; line=“请选择你要的操作\n1.增加学生 2.修改学生信息\n3.删除学生 4.浏览所有学生 信息\n5.统计学生人数 6.退出系统“; while(flag){JOptionPane.showMessageDialog(null,line,“结果“,JOptionPane.PLAIN_MESSAGE);input=JOptionPane.showInputDialog(“请输入数字,选择你要的操作“);value=Integer.parseInt(input);if(value==1){name=JOptionPane.showInputDialog(“请输入要添加的学生的名字:“);age=Integer.parseInt(JOptionPane.showInputDialog(“请输入要添加学生的年龄:“));student Student=new student(name,age);stuList.add(Student);/* Enumeration items=stuList.elements();Object o= items.nextElement();Student sample=(Student)o;JOptionPane.showMessageDialog(null,sample.getName(),“结果“,JOptionPane.PLAIN_MESSAGE);*/}else if(value==2){name=JOptionPane.showInputDialog(“请输入你要修改的学生的名字“);input=JOptionPane.showInputDialog(“请输入你要修改后的学生的年龄“);age=Integer.parseInt(input);Enumeration items=stuList.elements();while(items.hasMoreElements()){// String namestr=S; student Stu=(student)items.nextElement();if(Stu.getName().equals(name)){Stu.Update(age);break;}}JOptionPane.showMessageDialog(null,“修改成功!“,“结果 “,JOptionPane.PLAIN_MESSAGE);}else if(value==3){name=JOptionPane.showInputDialog(“请输入你要删除的学生的名字“);Enumeration items=stuList.elements();while(items.hasMoreElements()){// String namestr=S; student Stu=(student)items.nextElement();if(Stu.getName().equals(name)){stuList.remove(Stu);break;}}JOptionPane.showMessageDialog(null,“删除成功!“,“结果“,JOptionPane.PLAIN_MESSAGE);}else if(value==4){printVector(stuList);}else if(value==5){JOptionPane.showMessageDialog(null,“学生人数是“+stuList.size(),“结果 “,JOptionPane.PLAIN_MESSAGE);}else if(value==6){flag=false;}} } static public void printVector(Vector output){String line=““;if(output.isEmpty())JOptionPane.showMessageDialog(null,“The vector is empty“,“结果 “,JOptionPane.PLAIN_MESSAGE);else{Enumeration items=output.elements();while(items.hasMoreElements()){// String namestr=S; student Stu=(student)items.nextElement();line+=Stu.show();}JOptionPane.showMessageDialog(null,line,“学生信息如下 “,JOptionPane.PLAIN_MESSAGE);}}}public class student {String name;int age;static int count=0;public student(String str,int m){name=str;age=m;count++;}public void Update(int m){age=m;}public String getName(){return name;}public String show(){return “名字:“+name+“ 年龄:“+age+“\n“;} }。

      点击阅读更多内容
      关于金锄头网 - 版权申诉 - 免责声明 - 诚邀英才 - 联系我们
      手机版 | 川公网安备 51140202000112号 | 经营许可证(蜀ICP备13022795号)
      ©2008-2016 by Sichuan Goldhoe Inc. All Rights Reserved.