개발자노트
정렬 최소값/ 최대값을 이용한 Up/Down!
hansummer
2022. 6. 13. 17:36
package class04;
import java.util.Scanner;
public class Test05 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
// 1~100까지
int ans = 79; // 정답 정수
while (true) { // 몇번만에 맞출지 모르기 때문에 while문 사용
System.out.print("정답입력: ");
int num = sc.nextInt();
if (num == ans) {
System.out.println("정답입니다!");
break;
}
else if (num > ans) {
System.out.println("DOWN!");
}
else {
System.out.println("UP!");
}
}
}
}