java 职工信息管理_完整版)职工信息管理系统java源代码

本文提供了一个完整的Java职工信息管理系统源代码,包括职工类定义、操作类实现,支持信息输入、显示、查找、删除及数据保存与读取等功能。用户通过主菜单进行交互操作,实现对职工信息的管理。
摘要由CSDN通过智能技术生成

《完整版)职工信息管理系统java源代码》由会员分享,可在线阅读,更多相关《完整版)职工信息管理系统java源代码(10页珍藏版)》请在人人文库网上搜索。

1、package exercise;import java.io.*;class stafflnfo / 职工类publicStri ngn ame;publicStri ngnum;publicStri ngsex ;publicStri ngage ;publicStri ngrecordpublicStri ngpositi onpublicStri ngwangespublicStri ngtel ;publicStri ngaddr ;public class Staffl nfomation /实现部分throws IOExcepti onpublic static void mai。

2、n( final String args) staffInfo staffOne= new staffInfo100;for ( in t j=O;j1OO;j+)staffO nej = new staffI nfo();final ways staffTwo= new ways(); staffTwo.caida n(staffO ne);staffTwo.creat(staffO ne);staffTwo.output(staffO ne); staffTwo.search(staffO ne);staffTwo.delete(staffO ne);class ways /方法类,主要实。

3、现职工信息的建立,显示,查找,删除,信 息的保存与读 取;这个类是整个程序的操作类。public Stringrecordkeypublic String file name =public int i =0; /i用来存放职工的人数In fomati on .txt BufferedReader buf =newIn putStreamReader(System. i n );BufferedReader(newvoid caidan(staffI nfo staffOne)newfinal BufferedReaderInputStreamReader(System. in );throw。

4、s IOExcepti onbuf= new BufferedReader(/此处是JAVA语言中输入数据的基本格式,能有如C中的seanf函数int choice;doSystem. out .pri ntl n(1 );System.out.pri ntl n(! 职工管理系统主采单界面八 1 );Syste m.1 out.pri ntl n(1Syste m.1.输入职工信息1 );out.pri ntl n(1 1 );System.out.pri ntl n(1 2预览职工信息 1 );Syste m. 3.out .pri ntln(查找职工信息1 1);System.out.p。

5、ri ntl n(1 4.删除职工信息 1 );System.out.pri ntl n(1 5.读取已存数据 1 );System.out.pri ntl n(1 6?安全退出系统 1 );Syste m.out.pri ntl n(1System.i);out.pri nt(请输入您需要的功能代号(1-6):);choice=In teger.parse Int (buf.readL in e();switch (choice)case 1:creat(staffO ne);break ;case2:output(staffO ne);breakcase3:search(staffO ne。

6、);breakcase4:delete(staffO ne);breakcase 5:read(staffO ne);break ;case 6:save(staffO ne);break ;while (choice!=0);throws IOExcepti onvoid creat(staffI nfo staffO n e) finalBufferedReaderbuf= newBufferedReader(newInputStreamReader(System. in );System. out .print( 请输入职工信息 (以 0结束 )n );System. out .prin。

7、t( 姓名 : );staffOne i . name =buf.readLine(); / 用数组 staffOnei 来暂存职工的相 关信息while (staffOne i . name .compareTo( 0 )!=0) /用 compareTo 方法确定 判定是否应该写入新信息System. out .print( 工号 : );staffOne i . num=buf.readLine();System. out .print( 性别 : );staffOne i . sex =buf.readLine();System. out .print( 年龄 : );staffOne。

8、 i . age =buf.readLine();System. out .print( 学历 : );staffOne i . record =buf.readLine();System. out .print( 职位 : ); staffOne i . position =buf.readLine();System. out .print( 工资 : );staffOne i . wanges =buf.readLine();System. out .print( 电话 : );staffOne i . tel =buf.readLine();System. out .print( 住址 。

9、: );staffOne i . addr =buf.readLine();i +;System. out .println( 请输入下一个职工信息 : );staffOne i . name =buf.readLine(); void output(staffInfo staffOne) throws IOException /这里是实现“输 出(预览)职工信息” output的模块for ( int j=0;j i ;j+)if ( i !=0) System. out .println( );System. out .println( * 职工信息表 * );System. out .p。

10、rintln(IIfor ( in t j=0;j;j+)IISystem.相tt工资t电话号码dkey 等返回trueSystem out .pri ntln();out .println(姓名t工号tt性别tt住址);t年龄t学历t职位 .equals(staffO nej.num) /equals是子符串比较函数IIIISystem. out .println(II);II);System. out .pri nt(staffO nej.n ame +t +staffOpej.On ej. fOn ej.ys?em .potPafl.Onej/age +t +staffO nej.*工信。

11、息表O nej.+tt +staffO nej. wa nges +t addr +n);num+ trecord +t+sta)fO nej.+staff+staftel +System. out .println(II);System. out .pri ntl n(11);学历t职位ttSystem. out .println( II 姓名 t 工号性别 t 年龄t 电话号码tt 住址”);工资t没有职工信息!);else System. out .pri ntl n(System. out .println(IIvoidsearch(staffl nfo staffO ne)throw。

12、s IOExcepti onfinal BufferedReaderbuf= newBufferedReader(newIn putStreamReader(System.in );System. recordkftyFb(ean请输入您要查找的职工工号:);=buf.readL in e();flg= true ;System. out .pri ntln (staffO nej.n ame +t +staffO nej.num+ t +staffOn ej. sex +t +staffO nej. age +t +staffO nej. record +t +st affO nej. po。

13、sition +tt+staffO nej. wa nges +t +staffO nej. tel +t +staffO nej. addr +n);flg= false ;if (flg)System. out .pri ntln(” 对不起,查无此人!”);void delete(staffInfo staffOne) throws IOExceptionfinal BufferedReader buf= new BufferedReader( new In putStreamReader(System. i n );System. out .pri nt( 请输入您要删除的职工工号:)。

14、;recordkey =buf.readL in e();boolea n flg= true ;for ( in t j=0;j i ;j+)System. out .println( 输入的工号为:+recordkey );if ( recordkey .equals(staffO nej. num)for ( int k=j;k= i -1;k+) /利用顺序表的删除算法,删除值之后,再把后面的值往前移位,从而实现删除staffO nek.n ame =staffO nek+1.n ame ;staffO nek.num =staffO nek+1.num ;staffO nek.sex。

15、 =staffO nek+1.sex ;staffO nek.age =staffO nek+1.age ;staffO nek.record =staffO nek+1.record ;staffO nek.positi on =staffO nek+1.positi onstaffO nek.wan ges =staffO nek+1.wanges ;staffO nek.tel =staffO nek+1.tel ;staffO nek.addr =staffO nek+1.addr ;i -; /职工人数减一flg= false ;if (flg)System. out .pri nt。

16、ln(” 对不起,查无此人!。”);else System. out .println(已经删除该职工信息!。 ”);void save(staffl nfo staffO ne)把输入的职throws lOExcepti on/数据的保存模块,工信息保存到相应的文件里。FileWriter FileWriterint k; finalfw= new FileWriter(创建FileWnrtame类;的对象。用构造函数fw.write( ()+n ); /把职工的人数保存到文件中以便下次读取时使用i ;k+)/for ( k=0;k每个职工有9个信息字段,下面就是这 9个信息段。fw.wri。

17、te( staffO nek.n ame +n);fw.write( staffO nek.nu m+n);fw.write( staffO nek.sex +n);fw.write( staffO nek.age +n);fw.write( staffO nek.record +n)fw.write( staffO nek.positi on +nfw.write( staffO nek.wan ges +n)fw.write( staffO nek.tel +n);fw.write( staffO nek.addr +n);系统已经安全退出!感谢您的使用!);fw.close();Syst。

18、em.System.out .pri ntl n(exit (0);throws IOExcepti onvoidread(staffI nfo staffOne)final FileReader fr=final if ( iBufferedReader bfr=new FileReader( file name );new BufferedReader(fr);=ln teger.recordkey =bfr.readLi ne()!=for ( int j=0;j parseInt ( recordkey );null )staffO nej.staffO nej.staffO nej.。

19、staffO nej.staffO nej.staffO nej.staffO nej.staffO nej.staffO nej.fr.close();j+)n ame =bfr.readL in e(); num=bfr.readL in e(); sex =bfr.readL in e(); age =bfr.readL in e();record =bfr.readL in e(); position =bfr.readLine(); wan ges =bfr.readL in e(); tel =bfr.readL in e();addr =bfr.readL in e();System. out .println ( n 数据已经成功读取!。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值