zoukankan      html  css  js  c++  java
  • java基础:学员状态查询

     1 package kaoshi;
     2 /*
     3  * 学员状态查询
     4  * @作者:向往的生活
     5  * @时间:2017、3、7
     6  */
     7 import java.util.Scanner;
     8 
     9 public class StudentState {
    10     public static void main(String[] args) {
    11         boolean flag=false;
    12         while(true){
    13             Scanner scan=new Scanner(System.in);
    14             System.out.print("请输入学员状态的第一个英文字母:");
    15             String input = scan.nextLine().toUpperCase();
    16             char chr = input.toCharArray()[0];
    17             switch (chr) {
    18             case 'E':
    19                 System.out.println("优秀");
    20                 flag=enquire(flag);
    21                 break;
    22             case 'G':
    23                 System.out.println("良好");
    24                 
    25                 flag=enquire(flag);
    26                 break;
    27             case 'S':
    28                 System.out.println("中等");
    29                 flag=enquire(flag);
    30                 break;
    31             case 'F':
    32                 System.out.println("不合格");
    33                 flag=enquire(flag);
    34                 break;
    35 
    36             default:
    37                 System.out.println("输入错误,无法转换");
    38                 flag=enquire(flag);
    39                 break;
    40             }
    41             if(flag==true){
    42                 System.out.println("退出系统!");
    43                 System.exit(-1);
    44             }
    45         }    
    46     }
    47     /*
    48      * 选择是否要继续查询
    49      */
    50     public static boolean enquire(boolean flag){
    51         while(true){
    52             Scanner scan=new Scanner(System.in);
    53             System.out.print("	
    ");
    54             System.out.print("您想继续吗? (y/n)");
    55             String input6 = scan.nextLine();
    56             System.out.print("	
    ");
    57             input6 = input6.toUpperCase();
    58             char chr6 = input6.toCharArray()[0];
    59             if(chr6=='N'){
    60                flag=true;
    61                return flag;
    62             }
    63             else if(chr6=='Y'){
    64                 return flag;
    65             }
    66             else{
    67                 System.out.println("输入错误,重新输入!");
    68             }
    69             }
    70     }
    71 }
  • 相关阅读:
    广域网(ppp协议、HDLC协议)
    0120. Triangle (M)
    0589. N-ary Tree Preorder Traversal (E)
    0377. Combination Sum IV (M)
    1074. Number of Submatrices That Sum to Target (H)
    1209. Remove All Adjacent Duplicates in String II (M)
    0509. Fibonacci Number (E)
    0086. Partition List (M)
    0667. Beautiful Arrangement II (M)
    1302. Deepest Leaves Sum (M)
  • 原文地址:https://www.cnblogs.com/jichuang/p/6516160.html
Copyright © 2011-2022 走看看