/** InputSample.java */
package Lec07;
import java.io.*;//InputStreamReader クラスが含まれる
public class InputSample {
public static void main
(String[] args
){ //バイトストリームを文字ストリームに変換するため
System.
out.
print("Please input a charactor: "); // oh miss spell... //標準入力からバイトデータを読み込み単一の文字を返す
int c;
try {
c = isr.read();
System.
out.
println("Your input charactor is : "+(char)c
); e.printStackTrace();
}
}
}
/** Kadai2.java */
import java.io.*;
public class Kadai2 {
public static void main
(String[] args
) {
System.
out.
println("Please input a string: "); try {
str = bsr.readLine();
System.
out.
println("Your input string is : " + str
); System.
out.
println("A converted string is : " + convert
(str
)); e.printStackTrace();
}
}
StringBuilder convertedStr = new StringBuilder();
for (int i = 0; i < str.length(); i++) {
switch (str.charAt(i)) {
case 'a': convertedStr.append("x"); break;
case ' ': convertedStr.append(" "); break;
default: convertedStr.append("o");
}
}
return convertedStr.toString();
}
}
LyoqIElucHV0U2FtcGxlLmphdmEgKi8KcGFja2FnZSBMZWMwNzsKaW1wb3J0IGphdmEuaW8uKjsvL0lucHV0U3RyZWFtUmVhZGVyIOOCr+ODqeOCueOBjOWQq+OBvuOCjOOCiwpwdWJsaWMgY2xhc3MgSW5wdXRTYW1wbGUgewogIHB1YmxpYyBzdGF0aWMgdm9pZCBtYWluKFN0cmluZ1tdIGFyZ3MpewogICAgCS8v44OQ44Kk44OI44K544OI44Oq44O844Og44KS5paH5a2X44K544OI44Oq44O844Og44Gr5aSJ5o+b44GZ44KL44Gf44KBCgkJSW5wdXRTdHJlYW1SZWFkZXIgaXNyID0gbmV3IElucHV0U3RyZWFtUmVhZGVyKFN5c3RlbS5pbik7CgkJU3lzdGVtLm91dC5wcmludCgiUGxlYXNlIGlucHV0IGEgY2hhcmFjdG9yOiAiKTsgLy8gb2ggbWlzcyBzcGVsbC4uLgoJCS8v5qiZ5rqW5YWl5Yqb44GL44KJ44OQ44Kk44OI44OH44O844K/44KS6Kqt44G/6L6844G/5Y2Y5LiA44Gu5paH5a2X44KS6L+U44GZCgkJaW50IGM7CgkJdH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