mirror of
https://github.com/danbulant/introductionToProgramming
synced 2026-05-19 04:18:32 +00:00
11 lines
493 B
Java
11 lines
493 B
Java
public class RollLoadedDie {
|
|
public static void main(String[] args) {
|
|
double rand8 = Math.random() * 8.;
|
|
// floor returns double. Round gives long for double input, so conversion needed
|
|
int random = (int)(Math.floor(rand8) + 1);
|
|
// 1 - 8 to 1 - 6, with 6 receiving the probabilities of 7 - 8
|
|
// 1 - 5 have their original probabilities, meaning each have 1/8 chance of being selected, while 6 is 3/8
|
|
random = Math.min(random, 6);
|
|
System.out.println(random);
|
|
}
|
|
}
|