EDIT: I want to add that I am in a high school AP computer science class that is only at chapter6, I do not know what a heshmap is and I do not know what an array list is, I need to make this work by using For and While loops, and just arrays. I know I can do it only using that because my teacher did.
I'm working on a program that does exactly this for AP Compsci:
"Design and implement an application (IntegerCount.java) that reads a number of integers (in the range of 0 to 50 inclusive) that are entered by the user and counts how many times each integer is entered. After all input has been processed, print all of the values, with the number of times each one was entered. Hint: You will need a while loop, and make any number outside of the range the sentinel to end the program. Design: Output your results neatly, using tabs."
This so far right here is my code, which is the first half of the assignment.
package arrays;
import java.util.Scanner;
import java.util.Arrays;
public class IntegerCount {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
System.out.println("How many integers would you like to enter?");
int aCount = scan.nextInt();
int[] intcount;
intcount = new int[aCount];
System.out.println("Enter "+ aCount +"# of Ints");
for (int min = 0; min<intcount.length; min++){
Scanner scan1 = new Scanner(System.in);
intcount[min]= scan1.nextInt();
aCount--;
}
Arrays.sort(intcount);
System.out.print("| ");
for (int min = 0; min<intcount.length; min++){
System.out.print( intcount[min] + " | ");
}
}
}
However, I don't really understand or know how to implement the second part of the assignment which is to make it so they can't enter anything above 50, and that it counts the number of instances you enter a certain number. If anyone could add this code, and explain how it works that would be great, thank you. (I'm sure it will use a while loop, I haven't learned about an array list so don't implement it, thanks)