-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathL04Q05.java
50 lines (40 loc) · 1.55 KB
/
L04Q05.java
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
import java.util.*;
public class L04Q05 {
public static void main(String[] args){
Random random = new Random();
int player1Point = 0;
int player2Point = 0;
int point;
while(true){
System.out.println("Current point:");
System.out.println("Player 1 Point : " + player1Point);
System.out.println("Player 2 Point : " + player2Point);
do {
point = random.nextInt(6) + 1;
player1Point += point;
System.out.println("Player 1 roll a " + point);
if (player1Point > 100){
System.out.println("Player 1 Win the Game!");
break;
}
} while(point == 6);
if (player1Point > 100 || player2Point > 100){
break;
}
do {
point = random.nextInt(6) + 1;
player2Point += point;
System.out.println("Player 2 roll a " + point);
if (player2Point > 100){
System.out.println("Player 2 Win the Game!");
break;
}
} while(point == 6);
if (player1Point > 100 || player2Point > 100){
break;
}
}
System.out.println("Player 1 Point : " + player1Point);
System.out.println("Player 2 Point : " + player2Point);
}
}