学生信息管理系统--java

以下是我写的学生管理信息系统,保证原创,好不容易写出来的,拿去运行看看吧,有点模样哦 。

public class stuManager{
 public static void newline(){
  System.out.println();
 }
 public static void printstar(String words){
  System.out.print(words);
 }
 public static void printstar(int number, String flag){
   for (int i = 0;i < number ;i++ ){
    System.out.print(flag);
    
   }
 }
 public static void main(String[] args){
  String[] names = new String[35];
  String[] ids = new String[35];
  int counter = 0;
  java.util.Scanner sc = new java.util.Scanner(System.in);
   printstar (35 ,"*");
   newline();
   printstar (1 ,"*");
   printstar (33 ," ");
   printstar (1 ,"*");
   newline();
   printstar (1 ,"*");
   printstar (5," ");
   printstar("欢迎登陆北京德润科技!");
   printstar (6," ");
   printstar (1 ,"*");
   newline();
   printstar (1 ,"*");
   printstar (33 ," ");
   printstar (1 ,"*");
   newline();
   printstar (35 ,"*");
   newline();
  
   boolean isLogin = false ;
   while(true){
    if (!isLogin){
     System.out.println("--请选择相应的操作(对应菜单选项前的数字):");
     System.out.println("    0.登陆系统    1.关闭系统    ");
     String input = sc.nextLine();
     while(!"0".equals(input) && !"1".equals(input)){
      System.out.println("请输入正确的代码!");
      System.out.println("--请选择相应的操作(对应菜单选项前的数字):");
      System.out.println("    0.登陆系统    1.关闭系统    ");
      input = sc.nextLine();
     }
     if ("0".equals(input)){
       int counter1 = 0,counter2 = 0;
       System.out.println("请输入账号:");
       String username = sc.nextLine();
       counter1++;
       while(!"admin".equals(username)){
        if(counter1 == 4){
          System.out.println("账号错误!今天账号已锁定!");
          System.exit(0);
        }
        else if(counter1 < 4){
         int temp1=4-counter1;
         System.out.println("你还有"+temp1+"次机会!"+",请重新输入!");
         System.out.println("请重新输入账号:");
         username = sc.nextLine();
         counter1++;
        }
       }
       System.out.println("请输入密码:");
       String code = sc.nextLine();
       while(!"123456".equals(code)){
        if(counter2 == 4){
         System.out.println("密码错误,今天账号已锁定!");
         System.exit(0);
        }
        else if(counter2 <4){
         int temp2 = 4-counter2;
         System.out.println("你还有"+temp2+"次机会!请重新输入!");
         System.out.println("请输入密码:");
         code =sc.nextLine();
         counter2++;
        }
       System.out.println(username+"欢迎登陆本系统!!");
       
       }
       
     }
     else {
      System.exit(0);
     }
     isLogin =true ;
     
    }
    
    System.out.println("***********************************");
    System.out.println("请选择相应的操作:");
    System.out.println("            0.添加新成员");
    System.out.println("            1.删除新成员");
    System.out.println("            2.修改指定成员");
    System.out.println("            3.查看指定成员");
    System.out.println("            4.查看所有成员");
    System.out.println("            5.退出登陆");
    System.out.println("            6.关闭系统");
    System.out.println("***********************************");
    String operationNo = sc.nextLine();
    switch (operationNo){
    case "0":
     if (counter == ids.length){
      System.out.println("本班已满,请选着其他班级!");
     }
     else{
     System.out.println("请输入学生学号:");
     String id = sc.nextLine();
     System.out.println("请输入学生姓名:");
     String stuName = sc.nextLine();
     names[counter] =  stuName;
     ids[counter] = id;
     counter++;
     }
     break;
    case "1":
     if (counter == 0 ){
      System.out.println("本班学生人数为零!");
     }
     else{
      System.out.println("请输入要删除学生学号:");
      String id1 = sc.nextLine();
      for (int i = 0 ;i<counter ;i++ ){
       if (ids[i].equals(id1)){
        if(i != counter-1){
         for (int j = i;i<counter ;i++ ){
          names[i] = names [i+1];
         }
         
        }
        counter--;
        System.out.println("删除信息成功!");
       }
      }
     }
     break;
    case "2":
     if (counter == 0){
      System.out.println("班级学生为零!");
     }
     else{
      boolean update = false ;
      System.out.println("请输入要修改的学生学号:");
      String id2 = sc.nextLine();
      for (int i = 0;i<counter ;i++ ){
       if (ids[i].equals(id2)){
        System.out.println("请输入新的学生的姓名:");
        String name2 = sc.nextLine();
        names[i] = name2;
        update = true;
       }
      }
      if (update){
       System.out.println("修改信息成功!");
      }
      else{
       System.out.println("未找到修改信息,修改失败!");
      }
     }
     break;
    case "3":
     System.out.println("请输入要查看的学生学号:");
     String id3= sc.nextLine();
     boolean find = false ;
     for (int i = 0;i<counter;i++ ){
      if(ids[i].equals(id3)){
       System.out.println("学号: "+ids[i]+"  姓名: "+names[i]);
       find = true;
      }
     }
     if (!find){
      System.out.println("未找到该学生信息!");
     } 
     break;
    case "4":
     System.out.println("所有学生信息如下:");
     for (int i = 0 ;i<counter ;i++ ){
       System.out.println(ids[i]+"  "+names[i]);
     }
     break;
    case "5":
     isLogin =false;
     System.out.println("您已退出系统!");
     break;
    case "6":
     System.out.println("谢谢使用,再见!");
     System.exit(0);
    default:
     break;
    
    }
  }
    }
}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值