Write a public class call CountInts.class CountInts has a main method.CountInts must have two methods: count and displayResults.1. method count takes an array, aa, of ints and counts how many timeseach integer appears in aa. The integers can only be from 0 to 100inclusive.2. method display results displays the results of the count3. use the template provided. insert your code in the placesindicated and don't change anything else.
Examples
% java CountInts 0 1 2 3 4 5 2 3 4 5 4 5 5 [0,1, 2, 3, 4, 5, 2, 3, 4, 5, 4, 5, 5] 0 occurs ONE time 1 occurs ONEtime 2 occurs 2 times 3 occurs 2 times 4 occurs 3 times 5 occurs 4times % java CountInts 0 1 2 1000 -3 2 [0, 1, 2,1000, -3, 2] 0 occurs ONE time 1 occurs ONE time 2 occurs 2times
Template:
import java.util.*;
public class CountInts {
public static void count(int [] aa){
/*insert your code here */
}
public static void displayResults(){
/*insert your code here */
}
public static int [] readArray(){
Scanner input = new Scanner(System.in);
String ss = input.nextLine();
String [] aa = ss.split(\"[, ]\");
if(aa[0].length() == 0)
aa = new String[0];
//System.out.println(Arrays.toString(aa));
int [] dd = new int[aa.length];
int ii = 0;
for(String s : aa){
dd[ii++] = Integer.parseInt(s);
}
return dd;
}
public static void main (String[] args) {
int [] arr = readArray();
System.out.println(Arrays.toString(arr));
count(arr);
displayResults();
}
}