/** DieRoll.java - Generate a random number from 1 to 6, inclusive. * We will use the built-in Math.random() method that returns a * random x in the range 0 <= x < 1. But we want 1 <= n <= 6. * Let's assume that there is no input. */ public class DieRoll { public static void main(String [] args) { double x = Math.random(); // How do we convert [0, 1) to [1,2,3,4,5,6]? int answer = (int) (6 * x) + 1; System.out.println(answer); } }