import java.io.*;
public class TranseDemo {
public static void main(String[] args) throws IOException{
StringBuilder sb = new StringBuilder();
InputStream in = System.in;
int len = 0;
while(true){
len = in.read();
if(len == '\r')
continue;
if(len == '\n'){
String s = sb.toString();
if("over".equals(s))
break;
System.out.println(s.toUpperCase());
sb.delete(0, sb.length());
}
sb.append((char)len);
}
}
}
代码实现的功能是将键盘录入的字符转为大写输出,输入over是结束程序,但是这段代码运行后出现两个问题,1,出现自动换行的问题,2,输入over程序不结束?求高手解答改错
|