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

Book exercise 6.3: (Counting occurrence of numbers) Write a program that reads t

ID: 3620599 • Letter: B

Question

Book exercise 6.3: (Counting occurrence of numbers) Write a program that reads the integers between 1 and 100 and counts the occurrences of each. Assume the input ends with 0. Here is a sample run of the program (sample input is underlined for emphasis only):

Enter the integers between 1 and 100:
2 5 6 5 4 3 23 43 2 0
2 occurs 2 times
3 occurs 1 time
4 occurs 1 time
5 occurs 2 times
6 occurs 1 time
23 occurs 1 time
43 occurs 1 time

Note that if a number occurs more than one time, the plural word ”times” is used in the output. Also, note that the integers input will be between 1 and 100 but there may be more than 100 numbers input. Finally, note that for integers input 0 times, nothing is printed.

Explanation / Answer

Dear.... import java.util.Scanner; public class IntegerOccurrence { public static void main(String[] args) { int [ ] myint = new int[100]; int [ ] mycompare = new int[31]; int [ ] mycount = new int[31]; int i = 0, j = 0, k = 0, sum = 0; for(j=0;j