Write a program that generates?n?random ?integers between 0 and 9 and displays the count for each number. (
Write a program that generates n random integers between 0 and 9 and displays the count for each number. (Hint: Use an array of ten integers, say count, to store the counts for the number of 0s, 1s, . . . , 9s.)
A modular program is expected - use Methods. The program specifications are as below.
- In the main() method, declare an int array of size 10, named count.
- Implement a method populateCount(int[] cnt) that initializes the array to zero.
- Implement a method countNums(int[] cnt, int n) that accepts the count array and an integer n. The method should generate n random numbers in the range of 0 to 9. It should keep a count of how many times each number, 0 to 9; is generated in the array count.
- Implement a method printNums(int[] cnt) to print the count array. Note, print "time" or "times" – which ever is appropriate.
- Use basic structured programming and procedural programming.
- Write a main() method that declares the count array. Invokes the countNums() method with n = 10 followed by invoking the printNums(). Then invokes the countNums() method with n = 100 followed by printNums(). And again, invokes the countNums() method with n = 1000 followed by printNums().
- Make sure you invoke the populateCount(int[] cnt) method at appropriate times. And write out the heading for each set, n = 10, 100, and 1000.
- Documentation. Includes your name, create date and purpose of lab.
Collepals.com Plagiarism Free Papers
Are you looking for custom essay writing service or even dissertation writing services? Just request for our write my paper service, and we'll match you with the best essay writer in your subject! With an exceptional team of professional academic experts in a wide range of subjects, we can guarantee you an unrivaled quality of custom-written papers.
Get ZERO PLAGIARISM, HUMAN WRITTEN ESSAYS
Why Hire Collepals.com writers to do your paper?
Quality- We are experienced and have access to ample research materials.
We write plagiarism Free Content
Confidential- We never share or sell your personal information to third parties.
Support-Chat with us today! We are always waiting to answer all your questions.