import java.util.Scanner;
import java.util.Random;
public class OpenChallenge3 {
public OpenChallenge3() {
Scanner scan = new Scanner(System.in);
Random r = new Random();
while (true) {
int correct = r.nextInt(100); // 0-99까지의 임의의 수
int input = -1; // 유저가 입력한 수
int i = 1;
System.out.println("수를 결정하였습니다. 맞추어 보세요");
System.out.println("0-99");
// 유저가 답을 맞출때 까지 반복
while (true)
{
System.out.print(i+">>");
input = scan.nextInt();
if (input == correct)
break;
else if (input < correct)
System.out.println("더 높게");
else if (input > correct)
System.out.println("더 낮게");
i++;
}
System.out.println("맞았습니다.");
System.out.print("다시하겠습니까(y/n)>>");
scan.nextLine(); // 입력안 받고 넘어가는 것을 방지함
String exit = scan.nextLine();
// n을 입력하면 종료
if (exit.equals("n"))
break;
}
scan.close();
}
public static void main(String[] args) {
new OpenChallenge3();
}
}