Answer:
Check the explanation
Step-by-step explanation:
import java.util.Scanner;
public class Count
{
public static void main(String[] args)
{
// creating array of store to store count of
//every integer entered
int[] store = new int[51];
System.out.println("Enter any integers between"+
" 0 and 50, and if you are done then enter any"+
" integer out of the range");
System.out.println("Enter Integer: ");
//taking input of first integer
Scanner scan = new Scanner(System.in);
int integer = scan.nextInt();
//looping for integers entered in range
//to count its occurance
while(integer >= 0 && integer <= 51)
{
//adding count to 'store' array of that
//particular array of value entered
store[integer] = store[integer] + 1;
System.out.println("Enter Integer: ");
integer = scan.nextInt();
}
//printing number of times each integer is entered
System.out.println("printing number of times"+
" each integer is entered");
for (int i=0; i < 51; i++)
{
if (store[i] > 0)
System.out.println(i + ": " + store[i]);
}
}
}
Kindly check the result below