欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

java實現(xiàn)簡單學生成績管理系統(tǒng)

 更新時間:2022年02月24日 16:18:25   作者:LzyRapX  
這篇文章主要為大家詳細介紹了java實現(xiàn)簡單學生成績管理系統(tǒng),文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下

本文實例為大家分享了java實現(xiàn)學生成績管理系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

/*
?*@copyright by LzyRapx on 2016/4/12.
?*@name:java學生成績管理系統(tǒng).
?*@功能:學生相關信息,錄入,查詢,統(tǒng)計,修改等....
?*@PS:圖形界面的學生管理系統(tǒng)不要求就不做了.
?*/
?
import java.util.Scanner;
import java.lang.*;
import java.io.*;
class Student
{
?? ?private static Student[] s=new Student[100]; //錄入學生上限
? ? int n=0;
?? ?private String name;
?? ?private int num;
?? ?private String classAge;
?? ?private int chinese;
?? ?private int ?math;
?? ?private int english;
?? ?
?? ?//判斷是否有錄入學生信息
?? ?public void judge() throws IOException
?? ?{
?? ??? ?int i;
?? ??? ?char ch;
?? ??? ?String str;
?? ??? ?Scanner In=new Scanner(System.in);
?? ??? ?if(n==0)
?? ??? ?{
?? ??? ??? ?System.out.println("你還沒有錄入任何學生信息,是否錄入(Y/N):");
?? ??? ??? ?str=In.next();
?? ??? ??? ?ch=str.charAt(0);
?? ??? ??? ?while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("輸入有誤,請重新輸入:");
?? ??? ??? ??? ?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 ?//將異常拋出,調(diào)用這個方法去處理異常,如果main方法也將異常拋出,則交給Java虛擬機來處理,下同.
?? ?{
?? ??? ?int a;
?? ??? ?Scanner in=new Scanner(System.in);
?? ??? ?System.out.println("*************學生信息管理系統(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.退出管理系統(tǒng) ? ? ? ? ? ?******");
?? ??? ?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.out.println("成功退出系統(tǒng)?。?!");System.exit(0);break;
?? ??? ?}?? ??? ??? ?
?? ?}
?? ?
?? ?//錄入學生信息
?? ?public void add() throws IOException
?? ?{
?? ??? ?String str,str1,str2;
?? ??? ?int i,num1,t=1;
?? ??? ?char ch,ch1;
?? ??? ?FileWriter fw=new FileWriter("E://student.txt",true); ? //將學生信息錄入指定的txt文件中
?? ??? ?
?? ??? ?fw.write(" ? ? ? ? ? ? 錄入的學生信息列表\r\n\r\n學號 ? ?姓名 ? ?班級 ? ?語文成績 ? ? ?數(shù)學成績 ? ?英語成績\r\n");
?? ??? ?Scanner In=new Scanner(System.in);
?? ??? ?while(t==1)
?? ??? ?{
?? ??? ??? ?System.out.println("請輸入學生學號:");
?? ??? ??? ?num1=In.nextInt();
?? ??? ??? ?
?? ??? ??? ?//判斷學號是否重復
?? ??? ??? ?for(i=0;i<n;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.println("請輸入學生姓名:");
?? ??? ??? ?s[n].name=In.next();
?? ??? ??? ?fw.write(s[n].name+" ? ? ?");
?? ??? ??? ?System.out.println();
?? ??? ??? ?System.out.println("請輸入學生班級:");
?? ??? ??? ?s[n].classAge=In.next();
?? ??? ??? ?fw.write(s[n].classAge+" ?");
?? ??? ??? ?System.out.println("請輸入學生語文成績:");
?? ??? ??? ?s[n].chinese=In.nextInt();
?? ??? ??? ?fw.write(s[n].chinese+" ?"); ? ? ? ? ? ? ? ? ??
?? ??? ??? ?System.out.println("請輸入學生數(shù)學成績:");
?? ??? ??? ?s[n].math=In.nextInt();
?? ??? ??? ?fw.write(s[n].chinese+" ?");
?? ??? ??? ?System.out.println("請輸入學生英語成績:");
?? ??? ??? ?s[n].english=In.nextInt();
?? ??? ??? ?fw.write(s[n].english+"\r\n");
?? ??? ??? ?++n;
?? ??? ??? ?fw.close();?? ?
?? ??? ??? ?System.out.println();
?? ??? ??? ?System.out.println("是否繼續(xù)添加(Y/N)");
?? ??? ??? ?str=In.next();
?? ??? ??? ?ch=str.charAt(0);
?? ??? ??? ?while(ch!='N'&&ch!='n'&&ch!='Y'&&ch!='y')
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("輸入無效,請重新輸入:");
?? ??? ??? ??? ?str=In.next();
?? ??? ??? ??? ?ch=str.charAt(0);
?? ??? ??? ?}
?? ??? ??? ?if(ch=='N'||ch=='n')
?? ??? ??? ?{
?? ??? ??? ??? ?break;
?? ??? ??? ?}
?? ??? ?}
?? ??? ?System.out.println();
?? ??? ?System.out.print("是否返回系統(tǒng)主菜單(Y/N)");
?? ??? ?str1=In.next();
?? ??? ?ch1=str1.charAt(0);
?? ??? ?while(ch1!='Y'&&ch1!='y'&&ch1!='N'&&ch1!='n')
?? ??? ?{
?? ??? ??? ?System.out.println("輸入無效,請重新輸入:");
?? ??? ??? ?str1=In.next();
?? ??? ??? ?ch1=str1.charAt(0);
?? ??? ?}
?? ??? ?if(ch1=='Y'||ch1=='y')
?? ??? ?{
?? ??? ??? ?this.menu();
?? ??? ?}
?? ??? ?if(ch1=='N'||ch1=='n')
?? ??? ?{
?? ??? ??? ?System.out.println("");
?? ??? ??? ?System.out.println("你已退出系統(tǒng)?。?!");
?? ??? ??? ?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("學號\t姓名\t班級\t語文\t數(shù)學\t英語");
?? ??? ?for(i=0;i<n;i++) ? ? ? ? ? ? ? ? ? ? ? ?
?? ??? ?{
?? ??? ??? ?System.out.println(s[i].num+" ? ? ?"+s[i].name+" ? ? "+s[i].classAge+" ? ? "+s[i].chinese+" ? ? ?"+s[i].math+" ? ? "+s[i].english);
?? ??? ?}
?? ??? ?System.out.println("系統(tǒng)返回主菜單!");
?? ??? ?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.println("請輸入要刪除的學號:");
?? ??? ?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("系統(tǒng)將返回主菜單!");
?? ??? ??? ?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.println("你確定要刪除(Y/N):");
?? ??? ??? ?str=pin.next();
?? ??? ??? ?ch=str.charAt(0);
?? ??? ??? ?while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("輸入無效,請重新輸入:");
?? ??? ??? ??? ?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("E://student.txt"); ?//查看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.println("請輸入要修改的學號:");
?? ??? ?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("系統(tǒng)將返回主菜單!");
?? ??? ??? ?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("語文\t數(shù)學\t英語");
?? ??? ??? ?System.out.println(s[t].chinese+" ? ? ?"+s[t].math+" ? ? ?"+s[t].english);
?? ??? ??? ?System.out.println();
?? ??? ??? ?System.out.println("你確定要修改(Y/N):");
?? ??? ??? ?str=pin.next();
?? ??? ??? ?ch=str.charAt(0);
?? ??? ??? ?while(ch!='Y'&&ch!='y'&&ch!='N'&&ch!='n')
?? ??? ??? ?{
?? ??? ??? ??? ?System.out.println("輸入無效,請重新輸入:");
?? ??? ??? ??? ?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.修改學號 ? ? ? ? ? *****");
?? ??? ??? ??? ??? ?System.out.println("***** ? ? ? ? 2.修改班級 ? ? ? ? ? *****");
?? ??? ??? ??? ??? ?System.out.println("***** ? ? ? ? 3.修改姓名 ? ? ? ? ? *****");
?? ??? ??? ??? ??? ?System.out.println("****************************************");
?? ??? ??? ??? ??? ?System.out.println("請選擇:");
?? ??? ??? ??? ??? ?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("數(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<100;i++)
?? ??? ?{
?? ??? ??? ?s[i]=new Student();
?? ??? ?}
?? ??? ?stu.menu();
?? ?}
}

部分效果圖:

以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。

相關文章

  • JavaFX實現(xiàn)石頭剪刀布小游戲

    JavaFX實現(xiàn)石頭剪刀布小游戲

    這篇文章主要為大家詳細介紹了JavaFX實現(xiàn)石頭剪刀布小游戲,文中示例代碼介紹的非常詳細,具有一定的參考價值,感興趣的小伙伴們可以參考一下
    2019-05-05
  • Spring5中SpringWebContext方法過時的解決方案

    Spring5中SpringWebContext方法過時的解決方案

    這篇文章主要介紹了Spring5中SpringWebContext方法過時的解決方案,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2022-01-01
  • springBoot 過濾器去除請求參數(shù)前后空格實例詳解

    springBoot 過濾器去除請求參數(shù)前后空格實例詳解

    這篇文章主要為大家介紹了springBoot 過濾器去除請求參數(shù)前后空格實例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2022-11-11
  • Apache?Commons?BeanUtils:?JavaBean操作方法

    Apache?Commons?BeanUtils:?JavaBean操作方法

    這篇文章主要介紹了Apache?Commons?BeanUtils:?JavaBean操作的藝術,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進步,早日升職加薪
    2023-12-12
  • SpringBoot返回統(tǒng)一的JSON標準格式實現(xiàn)步驟

    SpringBoot返回統(tǒng)一的JSON標準格式實現(xiàn)步驟

    這篇文章主要介紹了SpringBoot返回統(tǒng)一的JSON標準格式,本文通過實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下
    2021-08-08
  • MongoDB整合Spring實例詳細講解(含代碼)

    MongoDB整合Spring實例詳細講解(含代碼)

    這篇文章主要介紹了MongoDB整合Spring實例詳細講解(含代碼),小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧
    2017-01-01
  • java網(wǎng)絡編程之識別示例 獲取主機網(wǎng)絡接口列表

    java網(wǎng)絡編程之識別示例 獲取主機網(wǎng)絡接口列表

    一個客戶端想要發(fā)起一次通信,先決條件就是需要知道運行著服務器端程序的主機的IP地址是多少。然后我們才能夠通過這個地址向服務器發(fā)送信息。
    2014-01-01
  • Java如何獲取相對路徑文件

    Java如何獲取相對路徑文件

    這篇文章主要介紹了Java如何獲取相對路徑文件問題,具有很好的參考價值,希望對大家有所幫助。如有錯誤或未考慮完全的地方,望不吝賜教
    2023-06-06
  • Java實現(xiàn)的圖片上傳工具類完整實例

    Java實現(xiàn)的圖片上傳工具類完整實例

    這篇文章主要介紹了Java實現(xiàn)的圖片上傳工具類,涉及java針對圖片文件的檢查、上傳、清除等相關操作技巧,需要的朋友可以參考下
    2017-10-10
  • 一文搞懂Java SPI機制的原理與使用

    一文搞懂Java SPI機制的原理與使用

    Java 程序員在日常工作中經(jīng)常會聽到 SPI,而且很多框架都使用了 SPI 的技術,那么問題來了,到底什么是 SPI 呢?今天小編就帶大家好好了解一下 SPI
    2022-10-10

最新評論