學(xué)生信息管理系統(tǒng)java版
本文為大家分享了java學(xué)生信息管理系統(tǒng)的源代碼,供大家參考,具體內(nèi)容如下
/*學(xué)生信息管理系統(tǒng),實(shí)現(xiàn)學(xué)生信息: *增加 int[] a=new int[9] *刪除 *查找 *更改 */ import java.util.Scanner;//導(dǎo)入java輸入流 import java.lang.*; import java.io.*; class Student { private static Student[] s=new Student[2]; int n=0; private String name; private int num; private String classAge; public void judge()throws IOException { int i; char ch; String str; Scanner In=new Scanner(System.in); if(n==0) { System.out.print("你還沒有錄入任何學(xué)生,是否錄入(Y/N):"); str=In.next(); ch=str.charAt(0); while(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(); } } } public void menu()throws IOException//定義菜單函數(shù) { int a;//定義switch語句變量 Scanner in=new Scanner(System.in);//實(shí)例化輸入流對象 System.out.println("*********學(xué)生信息管理系統(tǒng)功能表*********"); System.out.println("***** 1.增加 *****"); System.out.println("***** 2.顯示 *****"); System.out.println("***** 3.修改 *****"); System.out.println("***** 4.刪除 *****"); System.out.println("***** 5.查看 *****"); System.out.println("***** 0.退出 *****"); System.out.println("****************************************"); System.out.print("請選擇(0~5):"); a=in.nextInt(); while(a<0||a>5) { System.out.print("輸入超出范圍,請重新輸入:"); a=in.nextInt(); } switch(a) { case 1:this.add();break; case 2:this.show();break; case 3:this.modif();break; case 4:this.delete();break; case 5:this.look();break; case 0:System.exit(0);break; } } public void add()throws IOException//定義增加函數(shù) { String str,str1,str2; int i,num1,t=1; char ch,ch1; FileWriter fw=new FileWriter("F://javaFile//student.txt",true); fw.write(" 錄入的學(xué)生信息列表\r\n\r\n學(xué)號 姓名 班級\r\n"); Scanner In=new Scanner(System.in); while(t==1) { System.out.print("請輸入學(xué)生學(xué)號:"); num1=In.nextInt(); for(i=0;i<n;i++) { while(s[i].num==num1) { System.out.println("已存在此學(xué)號,請重新輸入"); System.out.print("請輸入學(xué)號:"); num1=In.nextInt(); } } s[n].num=num1; str2=String.valueOf(num1); fw.write(str2+" "); System.out.println(); System.out.print("請輸入學(xué)生姓名:"); s[n].name=In.next(); fw.write(s[n].name+" "); System.out.println(); System.out.print("請輸入學(xué)生班級:"); s[n].classAge=In.next(); fw.write(s[n].classAge+"\r\n"); ++n; fw.close(); System.out.println(); System.out.print("是否繼續(xù)添加(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+"位學(xué)生!"); System.out.println("你錄入的學(xué)生信息如下:"); System.out.println(); System.out.println("學(xué)號\t\t姓名\t班級"); for(i=0;i<n;i++) { System.out.println(s[i].num+" "+s[i].name+" "+s[i].classAge); } System.out.println("系統(tǒng)返回主菜單!"); this.menu(); } public void delete()throws IOException//刪除信息功能實(shí)現(xiàn) 注:本功能暫時不具備可擴(kuò)展性 { this.judge(); int j=0,t=0,k=0,num1; char ch; String str; Scanner pin=new Scanner(System.in); System.out.print("請輸入要刪除的學(xué)號:"); num1=pin.nextInt(); for(j=0;j<n;j++) { if(s[j].num==num1) { k=1; t=j; } } if(k==0) { System.out.println("對不起!你要刪除的學(xué)號不存在!"); System.out.println("系統(tǒng)將返回主菜單!"); this.menu(); } if(k==1) { System.out.println("你要刪除的學(xué)生信息如下:");//打印管理員要刪除的學(xué)生信息 System.out.println("學(xué)號\t姓名\t班級");//本功能暫時不備擴(kuò)展性 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("系統(tǒng)返回主菜單!"); this.menu(); } if(ch=='Y'||ch=='y') { for(j=t;j<n-1;j++) { s[j]=s[j+1]; } n--; System.out.println("數(shù)據(jù)成功刪除!"); System.out.println("系統(tǒng)返回主菜單!"); 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("系統(tǒng)返回主菜單!"); 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("請輸入要修改的學(xué)號:"); num2=pin.nextInt(); for(j=0;j<n;j++) { if(s[j].num==num2) { k=1; t=j; } } if(k==0) { System.out.println("對不起!你要修改的學(xué)號不存在!"); System.out.println("系統(tǒng)將返回主菜單!"); this.menu(); } if(k==1) { System.out.println("你要修改的學(xué)生信息如下:");//打印管理員要刪除的學(xué)生信息 System.out.println("學(xué)號\t姓名\t班級");//本功能暫時不備擴(kuò)展性 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("系統(tǒng)返回主菜單!"); this.menu(); } while(c==1) { if(ch=='Y'||ch=='y') { System.out.println("****************************************"); System.out.println("***** 1.修改學(xué)號 *****"); System.out.println("***** 2.修改班級 *****"); System.out.println("***** 3.修改姓名 *****"); System.out.println("****************************************"); System.out.print("請選擇:"); moi=pin.nextInt(); switch(moi) { case 1:System.out.print("請輸入新的學(xué)號:");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("數(shù)據(jù)已成功修改!"); } System.out.print("是否繼續(xù)修改(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("系統(tǒng)返回主菜單!"); 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(); } }
更多學(xué)習(xí)資料請關(guān)注專題《管理系統(tǒng)開發(fā)》。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
- java學(xué)生信息管理系統(tǒng)設(shè)計(jì)
- Java學(xué)生信息管理系統(tǒng)設(shè)計(jì)(數(shù)據(jù)庫版)
- java學(xué)生信息管理系統(tǒng)設(shè)計(jì)與實(shí)現(xiàn)
- java學(xué)生信息管理系統(tǒng)源代碼
- java實(shí)現(xiàn)簡單的學(xué)生信息管理系統(tǒng)代碼實(shí)例
- java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- 用java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)
- Java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)(使用數(shù)據(jù)庫)
- Java實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)超詳細(xì)教程
相關(guān)文章
Spring Security動態(tài)權(quán)限的實(shí)現(xiàn)方法詳解
這篇文章主要和小伙伴們簡單介紹下 Spring Security 中的動態(tài)權(quán)限方案,以便于小伙伴們更好的理解 TienChin 項(xiàng)目中的權(quán)限方案,感興趣的可以了解一下2022-06-06@FeignClient的使用和Spring?Boot的版本適配方式
這篇文章主要介紹了@FeignClient的使用和Spring?Boot的版本適配方式,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教2022-03-03java操作mongodb基礎(chǔ)(查詢 排序 輸出list)
java操作mongodb基礎(chǔ)學(xué)習(xí)查詢,排序,limit,輸出為list實(shí)例,大家參考使用吧2013-12-12Java面試之限流的實(shí)現(xiàn)方式小結(jié)
限流是指在各種應(yīng)用場景中,通過技術(shù)和策略手段對數(shù)據(jù)流量、請求頻率或資源消耗進(jìn)行有計(jì)劃的限制,本文為大家整理了常見的限流的實(shí)現(xiàn)方式,有需要的可以參考下2024-02-02java中ArrayList 、LinkList的區(qū)別分析
java中ArrayList 、LinkList的區(qū)別分析,需要的朋友可以參考一下2013-05-05idea創(chuàng)建SpringBoot自動創(chuàng)建Lombok無效果的問題解決方案
這篇文章主要介紹了idea創(chuàng)建SpringBoot自動創(chuàng)建Lombok無效果的問題解決方案,感興趣的朋友跟隨小編一起看看吧2024-12-12SpringBoot集成Nacos實(shí)現(xiàn)注冊中心與配置中心流程詳解
這篇文章主要介紹了SpringBoot集成Nacos實(shí)現(xiàn)注冊中心與配置中心流程,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)吧2023-02-02解決springmvc使用@PathVariable路徑匹配問題
這篇文章主要介紹了解決springmvc使用@PathVariable路徑匹配問題,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧2021-02-02簡單了解java volatile關(guān)鍵字實(shí)現(xiàn)的原理
這篇文章主要介紹了簡單了解volatile關(guān)鍵字實(shí)現(xiàn)的原理,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-08-08