Final answer:
To count the occurrence of numbers between 1 and 100 from user input, create an array of size 100 to store the count of each number. Use a while loop to read integers until 0 is entered, incrementing the count of the corresponding number. Iterate over the array and print out the count of each number that occurred.
Step-by-step explanation:
To count the occurrence of numbers between 1 and 100 from user input, you can create an array of size 100 to store the count of each number. Then, you can use a while loop to read integers from the user until they enter 0, and increment the count of the corresponding number in the array. Finally, you can iterate over the array and print out the count of each number that occurred.
For example:
int[] counts = new int[100];
Scanner scanner = new Scanner(System.in);
System.out.print("Enter the integers between 1 and 100: ");
int number = scanner.nextInt();
while (number != 0) {
counts[number - 1]++;
number = scanner.nextInt();
}
for (int i = 0; i < counts.length; i++) {
if (counts[i] > 0) {
System.out.printf("%d occurs %d times\\", i + 1, counts[i]);
}
}