■
答え……(for id:yurli)
public class sample1 { public static void main(String[] args) throws Exception { try { InputStreamReader is = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(is); Random rnd = new Random(); int target = rnd.nextInt(101); System.out.print("数字当て(0-100) = ?"); String strA = br.readLine(); int ges = Integer.parseInt(strA); while (ges != target) { if (ges > target) { System.out.println("もっと小さい"); } else if (ges < target) { System.out.println("もっと大きい"); } System.out.print("数字当て(0-100) = ?"); strA = br.readLine(); ges = Integer.parseInt(strA); } System.out.println("あたり"); } catch (Exception e) { e.printStackTrace(); throw (e); } } }
みたいな感じ。