Advertisement
MirkoVa

grafiek

Sep 15th, 2014
198
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. static int[] frequentie(String zin)
  2. {
  3.  
  4. int[] frequentie = new int[37];
  5. for(int i = 0; i < zin.length(); i++)
  6. {
  7. char c = zin.charAt(i);
  8. if(c >= 'a' && c <= 'z')
  9. frequentie[c-97] = frequentie[c-97] + 1;
  10. else if(c > '0' && c <= '9')
  11. frequentie[c-22] = frequentie[c-22] + 1;
  12. else if(c == ' ')
  13. frequentie[c+4] = frequentie[c+4] + 1;
  14. }
  15. System.out.println("--------------------------------------------------------------------------");
  16. System.out.println("Ter controle de frequenties van alle karakters: ");
  17. System.out.println(" ");
  18. float max = frequentie[0];
  19. float stapgrootte = 0;
  20. float sterretjes = 0;
  21. for(int i = 0; i < frequentie.length; i++)
  22. {
  23. System.out.print(frequentie[i] + " ");
  24.  
  25. if(frequentie[i] > max)
  26. max = frequentie[i];
  27.  
  28.  
  29. }
  30. if(max <= 10)
  31. stapgrootte = 1;
  32. else if(max > 10)
  33. stapgrootte = max/10;
  34. for(int i = 0; i < frequentie.length; i++)
  35. {
  36. sterretjes = frequentie[i]/stapgrootte;
  37.  
  38. if(sterretjes == 1.0)
  39. System.out.println(" * ");
  40.  
  41.  
  42.  
  43. }
  44.  
  45. System.out.println("");
  46.  
  47. System.out.println("a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9 ");
  48. System.out.println(" ");
  49. System.out.println("De max is " + max + " en de stappgrootte is " + stapgrootte);
  50. System.out.println("--------------------------------------------------------------------------");
  51.  
  52.  
  53.  
  54.  
  55.  
  56. return frequentie;
  57.  
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement