Guest User

Untitled

a guest
Feb 21st, 2018
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Frequency {
  3.  
  4.  
  5. public static void main(String[] args)
  6.  
  7. {
  8. Scanner scan = new Scanner(System.in);
  9.  
  10. int[] numbers;
  11.  
  12. System.out.print("enter numbers: ");
  13. int [] distribution = new int[51];
  14. Scanner scanner = new Scanner(System.in);
  15. while (true)
  16. {
  17. int num = scanner.nextInt();
  18. if (num <0 || num >50)
  19. {
  20. break;
  21. }
  22. distribution[num]++;
  23. }
  24.  
  25. for (int i=0;i<51;i++)
  26. {
  27. if (distribution[i]>0)
  28. {
  29. System.out.println(distribution[i]+" occurrences of " + i);
  30. }
  31. }
  32. }
  33. }
Add Comment
Please, Sign In to add comment