lettercheck2.java

来自「一些很简单的JAVA代码,一些人可以用上的」· Java 代码 · 共 27 行

JAVA
27
字号
public class LetterCheck2 {
  public static void main(String[] args) {
    char symbol = 'A';
    symbol = (char)(128.0*Math.random());        // Generate a random character

    if(symbol >= 'A' && symbol <= 'Z') {       // Is it a capital letter
      System.out.println("You have the capital letter " + symbol);

    } 
    else {
      if(symbol >= 'a' && symbol <= 'z') {    // or is it a small letter?
        System.out.println("You have the small letter " + symbol);

      } else {                                  // It is not less than z
        System.out.println("The code is not a letter");
      }
    }
  }
}

   } else {
      System.out.println("The code is less than A so it's not a letter");
    }
  }

}

⌨️ 快捷键说明

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