/**将用户输入的小写字符转换为大写字符,打印输出在屏幕上
* 如果用户输入的不是小写字符,则打印说明信息
**/
import java.io.*; public class FirstProgram { public static void main (String arg[]) { char a = ‘ ‘; System.out.print("Enter a character:"); try { a = (char)System.in.read(); } catch (IOException e) { }; if (a >= ‘a‘ && a <= ‘z‘) System.out.print("capital character is " + (char)(a - 32)); else if (a >=‘A‘ && a <= ‘Z‘) System.out.print(a +" is a capital character"); else System.out.print(a +" is other character"); } }
时间: 2024-11-13 17:53:28