-
Notifications
You must be signed in to change notification settings - Fork 74
Expand file tree
/
Copy pathupDown.java
More file actions
29 lines (22 loc) · 621 Bytes
/
upDown.java
File metadata and controls
29 lines (22 loc) · 621 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// 소스 코드 수정 중
// 깃허브연습
package game;
import java.util.Scanner;
public class upDown {
public static void main(String[] args) {
int answer = (int)(Math.random() * 100 + 1);
int guess;
int count = 0;
Scanner scan = new Scanner(System.in);
do {
System.out.print("정답을 추측하여 보세요 : ");
guess = scan.nextInt();
count++;
if(guess > answer)
System.out.println("다운!");
if(guess < answer)
System.out.println("업!");
} while(guess != answer);
System.out.println("축하합니다. 시도 횟수는 " + count + " 번 입니다.");
}
}