package chapter20230810;
import java.util.*;
public class test01 {
static Scanner stdIn = new Scanner(System.in);
static boolean confirmRetry() {
int cont;
do {
System.out.print("다시한번? <Yes-1/No-0> : ");
cont = stdIn.nextInt();
} while (cont != 0 && cont != 1);
return cont == 1;
}
public static void main(String[] args) {
Random rand = new Random();
System.out.println("암산 트레이닝!!");
do {
int x = rand.nextInt(90) + 10;
int y = rand.nextInt(90) + 10;
int z = rand.nextInt(90) + 10;
while (true) {
System.out.print(x + " + " + y + " + " + z + " = ");
int k = stdIn.nextInt();
if (k == x + y + z) {
System.out.println("정답입니다!");
break;
}else if (k > x + y + z) {
System.out.println("입력한 정수가 높습니다.");
}else {
System.out.println("입력한 정수가 낮습니다.");
}
}
} while(confirmRetry());
}
}