A. 数当て
A.
public class Kazuate {
public static void main(String[] args) throws IOException {
BufferedReader key = new BufferedReader(
new InputStreamReader(System.in));
double d = Math.random();
int ans = (int) (d * 100 + 1);
while (true) {
System.out.print("> ");
String input = key.readLine();
int x = Integer.parseInt(input);
if (ans == x) {
System.out.println("あたり!");
break;
}
if (ans > x) {
System.out.println("もっと大きい");
} else {
System.out.println("もっと小さい");
}
}
}
}
Q. setter, getterメソッドの定義
Q. setter, getterメソッドの定義 A.
以下のフィールドに対するアクセス用メソッドを定義しなさい。
private int age;
private String name;
private double height;
private boolean male;
private int[] englishScores;