基于Java的-学生信息管理系统

上传人:我*** 文档编号:136400149 上传时间:2020-06-28 格式:DOC 页数:9 大小:37KB
返回 下载 相关 举报
基于Java的-学生信息管理系统_第1页
第1页 / 共9页
基于Java的-学生信息管理系统_第2页
第2页 / 共9页
基于Java的-学生信息管理系统_第3页
第3页 / 共9页
基于Java的-学生信息管理系统_第4页
第4页 / 共9页
基于Java的-学生信息管理系统_第5页
第5页 / 共9页
点击查看更多>>
资源描述

《基于Java的-学生信息管理系统》由会员分享,可在线阅读,更多相关《基于Java的-学生信息管理系统(9页珍藏版)》请在金锄头文库上搜索。

1、package student;/主界面程序代码import java.io.*;import java.util.*;public class StudentManager public static void main(String args) throws Exception menu();public static boolean menu() throws Exception String infor=;/infor用来接收输入的内容。while (true) System.out.println(学生信息管理系统 其功能如下:);System.out.print(1.添加t);Sy

2、stem.out.print(2.浏览t);System.out.print(3.更新t);System.out.print(4.删除t);System.out.print(5.保存t);System.out.print(6.退出);System.out.println();Scanner in = new Scanner(System.in);int op = 0;System.out.println(请输入您要执行的功能的编号(1-6));op = in.nextInt();Function f=new Function();switch (op) case 1:infor=f.add()

3、;break;case 2:f.browse();break;case 3:infor=f.update();break;case 4:infor= (String) f.delete();break;case 5:f.save(infor);break;case 6:f.finish();/退出菜单界面return false;default:System.out.println(输入的数据错误,请重新输入!);/功能类代码package student;import java.io.*;import java.util.*;public class Function String info

4、r=;/infor用来接收输入的内容。/退出方法。public void finish() throws IOException, Exception System.out.println(已退出!);/保存方法。public void save(String sttr) throws IOException, Exception FileOutputStream f1=new FileOutputStream(xin.txt);/对每部操作进行保存ObjectOutputStream oos=new ObjectOutputStream(f1);oos.writeObject(sttr);S

5、ystem.out.println(已保存!);/实现删除的方法public Object delete() throws IOException, Exception System.out.println(原来的内容:);infor=information();System.out.println(infor);/S 用来接收删除后的内容String s=;Scanner sc =new Scanner(System.in);while(true)System.out.println(1.删除单个学生信息 t2.删除指定学生到该生以后的全部信息t3.删除指定两个学生(包括指定的第一个)之间的

6、全部信息t4.退出该操作);System.out.println(请输入要操作的序号:);int k3=sc.nextInt();/根据序号选择操作 。if(k3=1)TreeMap tm=new TreeMap();System.out.print(请输入要删除的学生学号:);String r=学号:+sc.next();String strarray=infor.split(n);for (int i = 0; i strarray.length; i+)String strarray1=strarrayi.split( );if(strarray10.equalsIgnoreCase(r

7、)strarray11=strarray11.replace(strarray11,);strarray10=strarray10.replace(strarray10,);tm.put(strarray10,strarray11);Set keySet=tm.keySet();Iterator t=keySet.iterator();while(t.hasNext()Object key=t.next();Object value=tm.get(key);s+=key+ +value+n;System.out.println(删除后的内容:);System.out.println(s);br

8、eak;else if(k3=2)System.out.print(请输入列表第一个学生的学号:);String id1=sc.next();int a=infor.indexOf(学号:+id1);/确定要删除的内容在文本的开始位置StringBuffer sb=new StringBuffer(infor);sb.delete(a,infor.length();/删除文本的从开始位置到最后的并且包含最后一个内容s=sb.toString();System.out.println(删除后的内容:);System.out.println(s);break;else if(k3=3)System

9、.out.print(请输入要删除的第一个学生的学号:);String id1=sc.next();int a=infor.indexOf(学号:+id1);/确定要删除的内容在文本的开始位置System.out.print(请输入要删除的最后一个学生的下一个学号:);String id2=sc.next();int b=infor.indexOf(学号:+id2);StringBuffer sb=new StringBuffer(infor);sb.delete(a,b);/删除文本的从开始位置到最后的一个内容的开始位置s=sb.toString();System.out.println(删

10、除后的内容:);System.out.println(s);break;else if(k3=4)break;elseSystem.out.println(输入错误!请重新输入!);return s;/实现更新的方法public String update() throws IOException, Exception Student stu=new Student();String str=information();/str接收读出来的“xin.txt”的内容。System.out.println(原来的内容:);System.out.println(str);Scanner sc=new

11、 Scanner(System.in);while(true)System.out.println(根据以下提示输入相关数字选择要操作的内容:);System.out.println(1.增加学生信息t2.更改学生信息t3.退出该操作);int k1=sc.nextInt();if(k1=1)System.out.println(请输入要增加的学生个数:);int k2=sc.nextInt();/要增加的学生个数TreeMap tm=new TreeMap();System.out.println(请输入要增加的学生信息:);for(int j=1;j=k2;j+)/循环增加多个学生信息。S

12、tring strarray=str.split(n);for (int i = 0; i strarray.length; i+)String strarray1=strarrayi.split( );tm.put(strarray10,strarray11);tm.put(stu.id(),stu.ps();Set keySet=tm.keySet();Iterator t=keySet.iterator();while(t.hasNext()Object key=t.next();Object value=tm.get(key);infor+=key+ +value+n;System.out.println(增加后的信息:n+infor);else if(k1=2)String str1=学号:;TreeMap tm=new TreeMap();System.out.println(请输入要修改的学生学号:);str1+=sc.next();System.out.print(请输入要被更改的内容:);String c=sc.next();System.out.

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 办公文档 > 事务文书

电脑版 |金锄头文库版权所有
经营许可证:蜀ICP备13022795号 | 川公网安备 51140202000112号