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

Java實(shí)現(xiàn)學(xué)生管理系統(tǒng)

 更新時(shí)間:2018年01月12日 10:58:40   作者:北京德潤(rùn)于大海  
這篇文章主要為大家詳細(xì)介紹了Java實(shí)現(xiàn)學(xué)生管理系統(tǒng),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

項(xiàng)目描述:通過(guò)管理員帳號(hào)登錄,對(duì)學(xué)員信息進(jìn)行管理??梢詫?shí)現(xiàn)學(xué)員信息的增加、修改、刪除、查詢。

知識(shí)點(diǎn):數(shù)組、do{}while循環(huán)、for循環(huán)、if語(yǔ)句、switch條件語(yǔ)句

學(xué)生管理系統(tǒng)的流程圖

import java.util.Scanner; 
public class Stu{ 
  public static void main(String[] args){ 
  Scanner sc = new Scanner(System.in); 
  boolean flag = false; 
  int stuNum = 0; 
  String[] stuName = new String[20]; 
  String[] stuId = new String[20]; 
  System.out.println("**********************************"); 
  System.out.println("*                *"); 
  System.out.println("*                *"); 
  System.out.println("* 歡迎使用德潤(rùn)科技教務(wù)管理系統(tǒng) *"); 
  System.out.println("*                *"); 
  System.out.println("*                *"); 
  System.out.println("**********************************"); 
  System.out.println("\n"); 
  do{ 
  System.out.println("************************"); 
  System.out.println("請(qǐng)輸入想要執(zhí)行的操作"); 
  System.out.println("1.登錄系統(tǒng)  2.退出系統(tǒng)"); 
  String num1 = sc.next(); 
  if(num1.equals("1")){ 
    flag = false; 
    break; 
  }if(num1.equals("2")){ 
    System.exit(0); 
    flag = false; 
  }else{ 
    System.out.println("輸入有誤請(qǐng)重新輸入"); 
    flag = true; 
    } 
  }while(flag); 
  do{ 
    System.out.println("請(qǐng)輸入登陸賬號(hào)"); 
    String username = sc.next(); 
    System.out.println("請(qǐng)輸入密碼"); 
    String password = sc.next(); 
  if(username.equals("tiantian")&&password.equals("dahai")){ 
    System.out.println("歡迎"+username); 
    flag = false; 
  }else{ 
    System.out.println("賬號(hào)或者密碼錯(cuò)誤,請(qǐng)重新登錄"); 
    flag = true; 
    } 
  }while(flag); 
  do{ 
  System.out.println("********************"); 
  System.out.println("請(qǐng)輸入想要進(jìn)行的操作"); 
  System.out.println("****************************************************************************"); 
  System.out.println("1.增加學(xué)員信息 2.刪除學(xué)員信息 3.修改學(xué)員姓名 4.查看學(xué)員信息 5.退出系統(tǒng)"); 
  System.out.println("****************************************************************************"); 
  String num2 = sc.next(); 
  switch(num2){ 
    case "1": 
      System.out.println("請(qǐng)輸入要添加的學(xué)員姓名"); 
      stuName[stuNum] = sc.next(); 
      System.out.println("請(qǐng)輸入要添加的學(xué)員學(xué)號(hào)"); 
      stuId[stuNum] = sc.next(); 
      stuNum++; 
      System.out.println("添加成功"); 
      flag = true; 
      break; 
    case "2": 
      System.out.println("請(qǐng)輸入想要?jiǎng)h除的學(xué)員的學(xué)號(hào)"); 
      String stuIdDel = sc.next(); 
      for(int i=0;i<stuName.length;i++){ 
      if(stuIdDel.equals(stuId[i])){ 
      stuId[i] = null; 
      stuName[i] = null; 
      }else{ 
      System.out.println("沒(méi)有此學(xué)員的學(xué)號(hào)"); 
      } 
      } 
      flag = true; 
      break; 
    case "3": 
      System.out.println("請(qǐng)輸入想要修改的學(xué)員的學(xué)號(hào)"); 
      String stuIdUp = sc.next(); 
      System.out.println("請(qǐng)輸入新的學(xué)員姓名"); 
      String stuNameUp = sc.next(); 
      for(int i=0;i<stuId.length;i++){ 
      if(stuIdUp.equals(stuId[i])){ 
      stuName[i] = stuNameUp; 
      }else{ 
      System.out.println("沒(méi)有此學(xué)員的學(xué)號(hào)"); 
      } 
      } 
      flag = true; 
      break; 
    case "4": 
      for(int i=0;i<stuName.length;i++){ 
      if(stuName[i]==null){ 
        continue; 
      } 
      System.out.println("學(xué)員的姓名為"+stuName[i]+"\t學(xué)員的學(xué)號(hào)為"+stuId[i]); 
      }   
      flag = true; 
      break; 
    case "5": 
      System.exit(0); 
    default: 
      System.out.println("輸入有誤請(qǐng)重新輸入!!!"); 
      flag = true; 
  } 
  }while(flag); 
   
   
  } 
} 

以下為優(yōu)化后的代碼

import java.util.Scanner; 
public class Stu{ 
  public static void main(String[] args){ 
  Scanner sc = new Scanner(System.in); 
  boolean flag = false; 
  boolean ss = true; 
  boolean aa = true; 
  boolean bb = true; 
  boolean cc = true; 
  int stuNum = 0; 
  String[] stuName = new String[20]; 
  String[] stuId = new String[20]; 
  String[] userNames = new String[5]; 
  String[] passWords = new String[5]; 
  System.out.println("*******************************************************"); 
  System.out.println("*                           *"); 
  System.out.println("*                           *"); 
  System.out.println("*      歡迎使用德潤(rùn)科技教務(wù)管理系統(tǒng)       *"); 
  System.out.println("*                           *"); 
  System.out.println("*                           *"); 
  System.out.println("*******************************************************"); 
  System.out.println("\n"); 
  do{ 
  System.out.println("************************"); 
  if(userNames[0]==null){ 
    System.out.println("請(qǐng)輸入想要執(zhí)行的操作(你還沒(méi)有登陸賬號(hào)請(qǐng)先注冊(cè))"); 
  }else{ 
    System.out.println("請(qǐng)輸入想要執(zhí)行的操作(您已注冊(cè)管理員身份,可以登錄系統(tǒng))"); 
    } 
  System.out.println("1.注冊(cè)帳號(hào) 2.登錄系統(tǒng) 3.忘記密碼 4.退出系統(tǒng)"); 
  String num1 = sc.next(); 
  switch(num1){ 
  case "1": 
    do{ 
    System.out.println("請(qǐng)輸入想要注冊(cè)的用戶名"); 
    userNames[stuNum] = sc.next(); 
    System.out.println("請(qǐng)輸入想要注冊(cè)的密碼"); 
    String password1 = sc.next(); 
    System.out.println("請(qǐng)?jiān)俅屋斎朊艽a"); 
    String password2 = sc.next(); 
    if(password1.equals(password2)){ 
    passWords[stuNum] = password1; 
    System.out.println("恭喜!帳號(hào):"+userNames[stuNum]+"創(chuàng)建成功"); 
    flag = true; 
    }else{ 
    System.out.println("兩次輸入的密碼不一致請(qǐng)重新創(chuàng)建"); 
    flag = false; 
    } 
    }while(!flag); 
    stuNum++; 
    continue; 
  case "2": 
    flag = false; 
    break; 
  case "3": 
    System.out.println("請(qǐng)輸入要查詢密碼的帳號(hào)"); 
    String username1 = sc.next(); 
    for(int i=0;i<userNames.length;i++){ 
      if(username1.equals(userNames[i])){ 
        System.out.println("帳號(hào)"+username1+"的密碼為"+passWords[i]); 
        aa = false; 
      } 
      flag = true; 
    } 
    if(aa == true){ 
        System.out.println("無(wú)此帳號(hào)信息"); 
        aa = true; 
        flag = true; 
      } 
    continue; 
  case "4": 
    System.exit(0); 
    flag = false; 
  default: 
    System.out.println("輸入有誤請(qǐng)重新輸入"); 
    flag = true; 
    } 
  }while(flag); 
  do{ 
    System.out.println("請(qǐng)輸入登陸賬號(hào)"); 
    String username = sc.next(); 
    System.out.println("請(qǐng)輸入密碼"); 
    String password = sc.next(); 
  for(int i=0;i<userNames.length;i++){ 
  if(username.equals(userNames[i])&&password.equals(passWords[i])){ 
    System.out.println("歡迎"+username); 
    ss = false; 
    break; 
  }   
  } 
  if(ss==true){ 
    System.out.println("賬號(hào)或者密碼錯(cuò)誤,請(qǐng)重新登錄"); 
    ss = true; 
  } 
   
  }while(ss); 
   
  do{ 
  System.out.println("********************"); 
  System.out.println("請(qǐng)輸入想要進(jìn)行的操作"); 
  System.out.println("****************************************************************************"); 
  System.out.println("1.增加學(xué)員信息 2.刪除學(xué)員信息 3.修改學(xué)員姓名 4.查看學(xué)員信息 5.退出系統(tǒng)"); 
  System.out.println("****************************************************************************"); 
  String num2 = sc.next(); 
  switch(num2){ 
    case "1": 
      System.out.println("請(qǐng)輸入要添加的學(xué)員姓名"); 
      stuName[stuNum] = sc.next(); 
      System.out.println("請(qǐng)輸入要添加的學(xué)員學(xué)號(hào)"); 
      stuId[stuNum] = sc.next(); 
      stuNum++; 
      System.out.println("添加成功"); 
      flag = true; 
      break; 
    case "2": 
      System.out.println("請(qǐng)輸入想要?jiǎng)h除的學(xué)員的學(xué)號(hào)"); 
      String stuIdDel = sc.next(); 
      for(int i=0;i<stuName.length;i++){ 
      if(stuIdDel.equals(stuId[i])){ 
      stuId[i] = stuId[stuId.length-1]; 
      stuName[i] = stuName[stuName.length-1]; 
      System.out.println("刪除成功!"); 
      flag = true; 
      cc = false; 
      } 
      }if(cc == true){ 
        System.out.println("沒(méi)有此學(xué)員的學(xué)號(hào)"); 
        flag = true; 
         
      } 
      break; 
    case "3": 
      System.out.println("請(qǐng)輸入想要修改的學(xué)員的學(xué)號(hào)"); 
      String stuIdUp = sc.next(); 
      for(int i=0;i<stuId.length;i++){ 
      if(stuIdUp.equals(stuId[i])){ 
      System.out.println("請(qǐng)輸入新的學(xué)員姓名"); 
      String stuNameUp = sc.next(); 
      stuName[i] = stuNameUp; 
      System.out.println("修改成功!"); 
      flag = true; 
      bb = false; 
      } 
      } 
      if(bb==true){ 
      System.out.println("沒(méi)有此學(xué)員的學(xué)號(hào)"); 
      flag = true; 
      }break; 
    case "4": 
      for(int i=0;i<stuName.length;i++){ 
      if(stuName[i]==null){ 
        continue; 
      } 
      System.out.println("學(xué)員的姓名為"+stuName[i]+"\t學(xué)員的學(xué)號(hào)為"+stuId[i]); 
      }   
      flag = true; 
      break; 
    case "5": 
      System.exit(0); 
    default: 
      System.out.println("輸入有誤請(qǐng)重新輸入!!!"); 
      flag = true; 
  } 
  }while(flag); 
  } 
} 

本代碼為Java初級(jí)人員編寫(xiě),方法運(yùn)用不是很恰當(dāng),僅供娛樂(lè)。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • 如何通過(guò)一張圖搞懂springBoot自動(dòng)注入原理

    如何通過(guò)一張圖搞懂springBoot自動(dòng)注入原理

    這篇文章主要給大家介紹了關(guān)于如何通過(guò)一張圖搞懂springBoot自動(dòng)注入原理的相關(guān)資料,文中通過(guò)圖文以及實(shí)例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下
    2022-02-02
  • Java基礎(chǔ)之詳細(xì)總結(jié)五種常用運(yùn)算符

    Java基礎(chǔ)之詳細(xì)總結(jié)五種常用運(yùn)算符

    在通常代碼邏輯處理中,我們常常都會(huì)使用到運(yùn)算符,今天我們就詳細(xì)了解一下運(yùn)算符的使用以及分類.運(yùn)算符是對(duì)常量或者變量進(jìn)行操作的符號(hào),它分為算術(shù)運(yùn)算符,賦值運(yùn)算符,比較運(yùn)算符,邏輯運(yùn)算符以及位運(yùn)算符.需要的朋友可以參考下
    2021-05-05
  • 一文帶你搞懂Java中Object類和抽象類

    一文帶你搞懂Java中Object類和抽象類

    這篇文章主要為大家詳細(xì)介紹了Java中Object類和抽象類的定義與使用,文中的示例代碼講解詳細(xì),對(duì)我們學(xué)習(xí)Java有一定幫助,需要的可以參考一下
    2022-08-08
  • 分布式任務(wù)調(diào)度xxl-job問(wèn)題解決

    分布式任務(wù)調(diào)度xxl-job問(wèn)題解決

    這篇文章主要為大家介紹了分布式任務(wù)調(diào)度xxl-job的問(wèn)題解決,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多多多進(jìn)步,早日升職加薪
    2022-03-03
  • 基于MyBatis的簡(jiǎn)單使用(推薦)

    基于MyBatis的簡(jiǎn)單使用(推薦)

    下面小編就為大家?guī)?lái)一篇基于MyBatis的簡(jiǎn)單使用(推薦)。小編覺(jué)得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過(guò)來(lái)看看吧
    2017-10-10
  • java.sql.SQLRecoverableException關(guān)閉的連接異常問(wèn)題及解決辦法

    java.sql.SQLRecoverableException關(guān)閉的連接異常問(wèn)題及解決辦法

    當(dāng)數(shù)據(jù)庫(kù)連接池中的連接被創(chuàng)建而長(zhǎng)時(shí)間不使用的情況下,該連接會(huì)自動(dòng)回收并失效,就導(dǎo)致客戶端程序報(bào)“ java.sql.SQLException: Io 異常: Connection reset” 或“java.sql.SQLException 關(guān)閉的連接”異常問(wèn)題,下面給大家分享解決方案,一起看看吧
    2024-03-03
  • Java Integer[]和int[]互相轉(zhuǎn)換方式

    Java Integer[]和int[]互相轉(zhuǎn)換方式

    這篇文章主要介紹了Java Integer[]和int[]互相轉(zhuǎn)換方式,具有很好的參考價(jià)值,希望對(duì)大家有所幫助,如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-12-12
  • Mybatis-Plus的使用詳解

    Mybatis-Plus的使用詳解

    這篇文章主要介紹了Mybatis-Plus的使用詳解,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧
    2020-10-10
  • Spring集成MyBatis?及Aop分頁(yè)的實(shí)現(xiàn)代碼

    Spring集成MyBatis?及Aop分頁(yè)的實(shí)現(xiàn)代碼

    這篇文章主要介紹了Spring集成MyBatis?及Aop分頁(yè)的實(shí)現(xiàn),本文通過(guò)實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2023-04-04
  • SpringMVC中的Model對(duì)象用法說(shuō)明

    SpringMVC中的Model對(duì)象用法說(shuō)明

    這篇文章主要介紹了SpringMVC中的Model對(duì)象用法說(shuō)明,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2021-06-06

最新評(píng)論