⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 help2.java

📁 Mcgraw-Hill - Java 2 - A Beginner S Guide, 2Nd Ed - 2003 -prog.
💻 JAVA
字号:
/* 
   Project 3-2 
 
   An improved Help system that uses a 
   a do-while to process a menu selection. 
*/ 
class Help2 { 
  public static void main(String args[])  
    throws java.io.IOException { 
    char choice; 
 
    do { 
      System.out.println("Help on:"); 
      System.out.println("  1. if"); 
      System.out.println("  2. switch"); 
      System.out.println("  3. for"); 
      System.out.println("  4. while"); 
      System.out.println("  5. do-while\n"); 
      System.out.print("Choose one: "); 
      do { 
        choice = (char) System.in.read(); 
      } while(choice == '\n' | choice == '\r');     
    } while( choice < '1' | choice > '5'); 
 
    System.out.println("\n"); 
  
    switch(choice) { 
      case '1': 
        System.out.println("The if:\n"); 
        System.out.println("if(condition) statement;"); 
        System.out.println("else statement;"); 
        break; 
      case '2': 
        System.out.println("The switch:\n"); 
        System.out.println("switch(expression) {"); 
        System.out.println("  case constant:"); 
        System.out.println("    statement sequence"); 
        System.out.println("    break;"); 
        System.out.println("  // ..."); 
        System.out.println("}"); 
        break; 
      case '3': 
        System.out.println("The for:\n"); 
        System.out.print("for(init; condition; iteration)"); 
        System.out.println(" statement;"); 
        break; 
      case '4': 
        System.out.println("The while:\n"); 
        System.out.println("while(condition) statement;"); 
        break; 
      case '5': 
        System.out.println("The do-while:\n"); 
        System.out.println("do {"); 
        System.out.println("  statement;"); 
        System.out.println("} while (condition);"); 
        break; 
    } 
  } 
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -