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.
Saturday, 20 August 2016
Chapter 7 Exercise 7, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.
Subscribe to:
Post Comments
(
Atom
)
No comments :
Post a Comment