• October 21st, 2013, 06:45 PM
supernowlin
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

What i have so far is

//Samuel Tate
//Itec 120
//Frequnency
// Will not complile

Code java:

```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]);     }     }```
• October 21st, 2013, 07:11 PM
Norm

[code=java]
[/code]
to get highlighting and preserve formatting.
• October 21st, 2013, 08:56 PM
AlexHail
You are using a rough format to break down and understand, might I suggest using brackets "{" & "}" to body your for loops, if-then statements, and while loops.

As of right now your while loop does nothing because you end the loop with a semi-colon directly after you initialize it.

Yours:
Code :

```while(condition); { // body }```

Correct:
Code :

```while(condition) { // body }```

Continue is not a keyword to be used inside an if-then statement, neither is break. Remove those
• October 21st, 2013, 11:14 PM
GoodbyeWorld