用java编写一个应用程序,判断从输入命令行输入的字符,

2025-02-27 12:44:38
推荐回答(2个)
回答1:

这个不难 ,主要注意 判断输出 和io流就行
import java.io.*;
public class PrintA{
public static void main(String[] args)throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入一串字母");
String s = br.readLine();
char str[] = s.toCharArray();
int i;
for(i=0;i if(str[i]>= 'a' &&str[i]<= 'z'){
str[i]-=32;
System.out.print(str[i]);
}
else{

System.out.print(str[i]);
}
}
}
}

回答2:

public static void main(String[] args) throws IOException {
int in;
while ((in = System.in.read()) != -1) {
if (in >= 'a' && in <= 'z')
in -= 32;
System.out.println((char) in);
}
}