怎样用java编写一个将小写字母转换成大写字母,若输入的不是小写字母则输出无法完成此操作

来源:百度知道 编辑:UC知道 时间:2024/05/26 16:34:09
快!!!!!!!!!!!!!

import java.io.* ;

class test {
public static void main(String[] args) throws IOException ,NotCharException{
try{

char r = Character.toUpperCase(getChar()) ;
System.out.println ( r) ;
}catch(NotCharException e){
throw new NotCharException() ;
}
}

public static char getChar() throws IOException {
String s = getString() ;
return s.charAt(0) ;
}
public static String getString() throws IOException {

BufferedReader b = new BufferedReader( new InputStreamReader( System.in ) );
String s = b.readLine() ;
return s ;
}
}

class NotCharException extends IOException {

NotCharException(){
System.out.println ( " 无法完成此操作 ") ;
}
}

运行方式 :

java ConvertAlpha 参数 例如:
java ConvertAlpha a

---------------源程序-------------------------------
public class ConvertAlp