Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program that generates N random numbersbetween 1 and 15 (N is entered by

ID: 3610986 • Letter: W

Question

Write a program that generates N random numbersbetween 1 and 15 (N is entered by the user). The program must thenprint the generated numbers to the screen and only keep thenumbers less than or equal 10. Finally, your program must count theoccurrences of each generated number within the new list and printthe counts along with the final array elements.

Sample output:

Enter N: 20

20 Random numbers generated:

10 3 15 3 1 1 2 14 12 5 5 7 7 8 10 2 12 11 10 9

Final List:

10 3 3 1 1 2 5 2 7 7 8 10 2 10 9

Count 1: 2

Count 2: 3

Count 3: 2

Count 4: 0

Count 5: 1

Count 6: 0

Count 7: 2

Count 8: 1

Count 9: 1

Count 10: 3

Explanation / Answer

/* compile "javac CountRandInts.java run "java CountRandInts" */ import java.io.*; import java.util.*; import java.lang.*; public class CountRandInts{ public static int[] count ={0, 0, 0, 0, 0, 0, 0, 0, 0,0}; public static String s=""; public static void main(String args[]){ System.out.println("Enter N: "); int number=0; try{    number = Integer.parseInt (newBufferedReader(new InputStreamReader(System.in)).readLine());    System.out.println(); } catch (Exception e){    e.printStackTrace(); } int i=0; Random r = new Random(); int value =0; System.out.println(number + " random numbers generated"); while(i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote