forked from google/codeu_coding_assessment_2017
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiceP.java
More file actions
47 lines (45 loc) · 996 Bytes
/
DiceP.java
File metadata and controls
47 lines (45 loc) · 996 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import java.util.*;
public class DiceP {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
double rounds= s.nextInt();
first(rounds);
}
public static void first(double rounds) {
double count=0;
Random generator= new Random();
for (int i=1; i<=rounds; i++) {
double x= generator.nextInt(6)+1;
double y= generator.nextInt(6)+1;
double z= generator.nextInt(6)+1;
count+=1;
while x, y, z not equal 6
if (x!=6 && z==6) {
System.out.printf("%4f",count/rounds);
System.out.println();
break;
}
else if (y!=6 && z==6) {
System.out.printf("%4f",count/rounds);
System.out.println();
break;
}
else if (z==6){
System.out.printf("%4f",count/rounds);
System.out.println();
break;
}
}
}
}
/* while (!console.hasNextInt()) {
console.next();
}
return console.nextInt(); */
/*if (x==6) {
System.out.println("BOB");
}
else if (y==6) {
System.out.println("COB");
}
*/