public class ProgrammingEx7_7 { public static void main(String[] args) { int[] numbers = new int[10]; for (int i = 0; i < 100; i++) { numbers[intRandom(0, 9)]++; } for (int i = 0; i < numbers.length; i++) { System.out.println("Number " + i + " appears " + numbers[i] + " times." ); } } public static int intRandom(int lowerBound, int upperBound) { return (int) (lowerBound + Math.random() * (upperBound - lowerBound + 1)); } }
Access to bulk amount of Study Resources, Course Notes, Test Prep, 24/7 Homework Help, solution manuals, homework help and more.
Pages
▼
No comments:
Post a Comment