Advertisement
Guest User

Untitled

a guest
Apr 1st, 2020
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.84 KB | None | 0 0
  1. package zahalkacv07;
  2.  
  3. class cetnostZnaku {
  4.  
  5.     cetnostZnaku() {
  6.  
  7.     }
  8.  
  9.     public static void znakyS(String retezec) {
  10.  
  11.         String prevod = retezec.toLowerCase();
  12.  
  13.         cyklus(prevod, prevod.length(), 's');
  14.         cyklus(prevod, prevod.length(), 'a');
  15.         cyklus(prevod, prevod.length(), 'o');
  16.         cyklus(prevod, prevod.length(), 'i');
  17.         cyklus(prevod, prevod.length(), 'r');
  18.         cyklus(prevod, prevod.length(), 'e');
  19.     }
  20.  
  21.     public static void cyklus(String retez, int delkaRetezce, char hledanyZnak) {
  22.         char pismeno = hledanyZnak;
  23.         int pocet = 0;
  24.  
  25.         for (int i = 0; i < delkaRetezce; i++) {
  26.             if (retez.charAt(i) == pismeno) {
  27.                 pocet++;
  28.             }
  29.  
  30.         }
  31.         System.out.println("V řetězci je znak " + hledanyZnak + " : " + pocet);
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement