/** RandomDemo1 @author John Doe Per 3 */ public class RandomDemo1 { public static void main(String[] args) { int num = 0; // random number // ************************************************************ // Display 5 pseudorandom integers between 1 & 6 inclusive separated // by spaces on one line of output. Multiple occurrences of // integers may occur. for (int i = 0; i < 5; i++) { num = (int) (Math.random() * 6) + 1; System.out.print(num + " "); } System.out.println(); // notice the logic error that occurs below when parentheses are not used // to override the order of operations for (int i = 0; i < 5; i++) { num = (int) Math.random() * 6 + 1; System.out.print(num + " "); // always displays 1 } } }