I just started learn this stuff and im not doing to well so far. So any help is welcome.
Design and implement an application that reads an arbitrary number of integers that are in the range 0 to 50 inclusive and counts how many occurrences of each are entered. Stop reading input when any integer outside the range 0 to 50 is encountered. After all input has been processed, print all of the values (with the number of occurrences) that were entered one or more times.
Prompt for input with System.out .print("enter numbers: ").
The output should be one frequency count per line. For example:
enter numbers: 2 2 5 5 5 5 5 5 2 5 -1
3 occurrences of 2
7 occurrences of 5
SPECIFICATION OF NAMES: Please name your application class Frequency
What i have so far is
//Samuel Tate
//Itec 120
//Frequnency
// Will not complile
import java.util.Scanner; public class Frequency { public static void main (String[] args) { int input = 0; int[] integers = new int[51]; Scanner scan = new Scanner(System.in); while(input != 51); { System.out.print("Enter an arbitrary number of integers in the range 0-50 (enter 51 to exit) : "); input = scan.nextInt(); if(input == 51) break; if(input < 0 || input > 50){ System.out.println("number out of range"); } integers[input]++; continue; } for(int index = 0; index < 51; index++); if(integers[index] > 0) System.out.println(index + ": " + integers[index]); } }