Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Frequency {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int[] numbers;
- System.out.print("enter numbers: ");
- int [] distribution = new int[51];
- Scanner scanner = new Scanner(System.in);
- while (true)
- {
- int num = scanner.nextInt();
- if (num <0 || num >50)
- {
- break;
- }
- distribution[num]++;
- }
- for (int i=0;i<51;i++)
- {
- if (distribution[i]>0)
- {
- System.out.println(distribution[i]+" occurrences of " + i);
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment