首页 > 编程知识 正文

java实现学生信息管理系统(java学生信息管理系统源代码)

时间:2023-05-05 17:38:22 阅读:123341 作者:4610

/*学生信息管理系统,学生信息实现: *int[]a=newint[9]*删除*搜索*更改*//*学生信息管理系统,学生信息实现: *int[]a=newint[9]*删除*搜索* import java.io.*; class student { privatestaticstudent [ ] s=new student [2]; int n=0; 私有字符串名称; 私密int num; 私有字符串类; 公共语音冗余(throwsioexception { inti; char ch; 字符串str; sannerin=newscanner(system.in; if(n==0) ({System.out.print ) )你还没有注册任何学生。 ((Y/N ) : ) ) ) ) ) ) ) ) 652 str=In.next (; ch=str.Charat(0; 威尔(ch!='Y'ch!='y'ch!='N'ch!='n'(system.out.print )输入有误。 请重新输入: )。 str=In.next (; ch=str.Charat(0; }if(ch=='y'|ch=='y ' ) {this.add ); }if(ch=='n'|ch=='n ' ) {this.menu ); } }公共void menu () throws IOException//) /定义菜单函数({int a; switch语句变量scanner in=定义new scanner (system.in )//输入流对象system.out.println(*******学生信息管理系统菜单***** system.out.println('****2.显示***** ' ); system.out.println('****3.修改***** ' ); system.out.println('****4.删除***** ' ); system.out.println('*****5.评论**** ' ); system.out.println('*****0.退出**** ' ); system.out.println (' * * * * * * * * * * * * * * * * * * * * * * * * * * * ) () ) ) ) a=in.nextInt (; 如果输入的内容不在while(a0||a5 ) {System.out.print )范围内,请重新输入: )。 a=in.nextInt (; }switch(a ) {case 1:this.add ); 布雷克; case 2:this.show (; 布雷克; case 3:this.modif (; 布雷克; case 4:this.delete (; 布雷克; case 5:this.look (; 布雷克; case0:system.exit(0; 布雷克; }公共语音添加(throwsioexception//定义增量函数({String str,str1,str2; int i,num1,t=1; char ch、ch1; filewriter fw=new filewriter (' f ://Java file//student.txt ',true ); fw.write ('输入的学生信息列表rnrn学号名称班rn ' ); sannerin=newscanner(system.in; 请输入while(t==1) ({System.out.print ) )学生学号: ) )。 num1=In.nextInt (; for(I=0; in; I () while ) s[I].num==num1) ({System.out.println ) )此学号已存在。 请再输入一次) ) ); 请输入System.out.print ('学号: '; num1=In.nextInt (; }}s[n].num=num1; str2=string.valueof(num1); fw.write(str2' ); System.out.println (; 请输入System.out.print ('学生姓名: '; s[n].name=In.next (; fw.write(s[n].name ' ); System.out.println (; 请输入System.out.print ('学生班: '; s[n].classAge=In.next (; fw.write(s[n].classage'rn '; n; fw.close (; System.out.println ();System.out.print("是否继续添加(Y/N)");str=In.next();ch=str.charAt(0);while(ch!='N'&&ch!='n'&&ch!='Y'&&ch!='y'){System.out.print("输入有误,请重新输入:");str=In.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){break;}}System.out.println();System.out.print("是否返回主菜单(Y/N)");str1=In.next();ch1=str1.charAt(0);while(ch1!='Y'&&ch1!='y'&&ch1!='N'&&ch1!='n'){System.out.print("输入有误,请重新输入:");str1=In.next();ch1=str1.charAt(0);}if(ch1=='Y'||ch1=='y'){this.menu();}if(ch1=='N'||ch1=='n'){System.out.println("正在退出...谢谢使用!");System.exit(0);}}public void show()throws IOException{int i;this.judge();System.out.println("本次操作共录入"+n+"位学生!");System.out.println("你录入的学生信息如下:");System.out.println();System.out.println("学号tt姓名t班级");for(i=0;i<n;i++) {System.out.println(s[i].num+" "+s[i].name+" "+s[i].classAge);}System.out.println("系统返回主菜单!");this.menu();}public void delete()throws IOException//删除信息功能实现 注:本功能暂时不具备可扩展性{this.judge();int j=0,t=0,k=0,num1;char ch;String str;Scanner pin=new Scanner(System.in);System.out.print("请输入要删除的学号:");num1=pin.nextInt();for(j=0;j<n;j++){if(s[j].num==num1){k=1;t=j;}}if(k==0){System.out.println("对不起!你要删除的学号不存在!");System.out.println("系统将返回主菜单!");this.menu();}if(k==1){System.out.println("你要删除的学生信息如下:");//打印管理员要删除的学生信息System.out.println("学号t姓名t班级");//本功能暂时不备扩展性System.out.println(s[t].num+" "+s[t].name+" "+s[t].classAge);System.out.println();System.out.print("你确定要删除(Y/N):");str=pin.next();ch=str.charAt(0);while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输入有误,请重新输入:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){System.out.println();System.out.println("系统返回主菜单!");this.menu();}if(ch=='Y'||ch=='y'){for(j=t;j<n-1;j++){s[j]=s[j+1];}n--;System.out.println("数据成功删除!");System.out.println("系统返回主菜单!");this.menu();}}}public void look()throws IOException{FileReader fr=new FileReader("F://javaFile//student.txt");int a;while((a=fr.read())!=-1){System.out.print((char)a);}fr.close();System.out.println("系统返回主菜单!");System.out.println();this.menu();}public void modif()throws IOException{this.judge();int j=0,t=0,k=0,num2,num3,moi,c=1;char ch;String str,str1,str2;Scanner pin=new Scanner(System.in);System.out.print("请输入要修改的学号:");num2=pin.nextInt();for(j=0;j<n;j++){if(s[j].num==num2){k=1;t=j;}}if(k==0){System.out.println("对不起!你要修改的学号不存在!");System.out.println("系统将返回主菜单!");this.menu();}if(k==1){System.out.println("你要修改的学生信息如下:");//打印管理员要删除的学生信息System.out.println("学号t姓名t班级");//本功能暂时不备扩展性System.out.println(s[t].num+" "+s[t].name+" "+s[t].classAge);System.out.println();System.out.print("你确定要修改(Y/N):");str=pin.next();ch=str.charAt(0);while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输入有误,请重新输入:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){System.out.println();System.out.println("系统返回主菜单!");this.menu();}while(c==1){if(ch=='Y'||ch=='y'){System.out.println("****************************************");System.out.println("***** 1.修改学号 *****");System.out.println("***** 2.修改班级 *****");System.out.println("***** 3.修改姓名 *****");System.out.println("****************************************");System.out.print("请选择:");moi=pin.nextInt();switch(moi){case 1:System.out.print("请输入新的学号:");num3=pin.nextInt();s[t].num=num3;break;case 2:System.out.print("请输入新的班级:");str1=pin.next();s[t].classAge=str1;break;case 3:System.out.print("请输入新的姓名:");str2=pin.next();s[t].name=str2;break;}System.out.println("数据已成功修改!");}System.out.print("是否继续修改(Y/N)");str=pin.next();ch=str.charAt(0);System.out.println();while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n'){System.out.print("输入有误,请重新输入:");str=pin.next();ch=str.charAt(0);}if(ch=='N'||ch=='n'){break;}}}System.out.println();System.out.println("系统返回主菜单!");this.menu();}public static void main(String[] args)throws IOException{Student stu=new Student();for(int i=0;i<2;i++){s[i]=new Student();}stu.menu();}}

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。