import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner scan = new Scanner (System.in); int enteredNum; enteredNum = 0; int[] countArray; countArray = new int[51]; boolean SENTINEL = false; System.out.println("Enter an integer between 0 and 50 (enter '99' to quit): "); while (enteredNum != 99) { enteredNum = scan.nextInt(); if (enteredNum < countArray.length && enteredNum >= 0 && enteredNum <= 50) { countArray[enteredNum]++; } } for(int count = 0; countArray[count] >= 0; count++) { if (countArray[count] != 0) { System.out.println("Array slot " + count + ":" + countArray[count]); } } } }