-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathbabo.java
More file actions
53 lines (45 loc) · 1.51 KB
/
babo.java
File metadata and controls
53 lines (45 loc) · 1.51 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
// 페널티 액수 정하기!
import java.util.Scanner;
public class babo {
static Scanner scan = new Scanner(System.in);
public static void main(String[] args) {
int menuChoice = 0;
while (menuChoice != 4) {
displayMenu();
menuChoice = getMenuChoice();
if (menuChoice == 1) {
int min = 1;
int max = 10;
int rand_num = (int)Math.floor(Math.random()*(max-min+1)+min);
System.out.println(rand_num +"000" + "원");
}
else if (menuChoice == 2){
int min = 2;
int max = 50;
int rand_num = (int)Math.floor(Math.random()*(max-min+1)+min);
System.out.println(rand_num +"000" + "원");
}
else if (menuChoice == 3){
int min = 50;
int max = 100;
int rand_num = (int)Math.floor(Math.random()*(max-min+1)+min);
System.out.println(rand_num +"000" + "원");
}
else if (menuChoice == 4)
System.out.println("===== 프로그램을 끝냅니다! 다음에는 벌금을 내지 않도록 조심하세요! =====");
else
System.out.println(" !!! 유효하지 않은 선택입니다 !!!");
}
}
static void displayMenu() {
System.out.println("===== 페널티 메뉴 =====");
System.out.println("1. 1회 불참");
System.out.println("2. 2회 불참");
System.out.println("3. 3회 불참");
System.out.println("4. 끝");
}
static int getMenuChoice() {
System.out.print("선택을 입력 해주세요 --> ");
return scan.nextInt();
}
}