Facebook
From Łukasz, 6 Years ago, written in Java.
Embed
Download Paste or View Raw
Hits: 284
  1.  
  2. package PracaDomowa5;
  3.  
  4. import java.util.HashMap;
  5. import java.util.Map;
  6. import java.util.Scanner;
  7.  
  8.  
  9. public class Words {
  10.    
  11.    
  12.     public static void main(String[] args) {
  13.         String word1 = "Wlazl kotek na plotek";
  14.         System.out.println("Wlzazl kotek na plotek --> " + word1.substring(6).replace("ek", "").
  15.                 replace("plot", "most"));
  16.         String word2 = new String("Dobry wieczor");
  17.         System.out.println("Dobry wieczor --> " + word2.replace("obry", "zien").
  18.                 replace("wieczor", "dobry"));
  19.         String word3 = "Zielona pilka";
  20.         System.out.println("Zielona pilka --> " + word3.replace("ielona", "lapalem").
  21.                 replace("pilka", "pilke"));
  22.         Scanner s = new Scanner(System.in);
  23.         System.out.println("Podaj zdanie: ");
  24.         String word = s.nextLine();
  25.          
  26.        
  27.         Map<Character, Integer> map = new HashMap<>();
  28.         for (int i = 0; i < word.length(); i++) {
  29.             char c = word.charAt(i);
  30.             if (c == 'A' || c == 'a' || c == 'E' || c == 'e' || c == 'I'
  31.                     || c == 'i' || c == 'O' || c == 'o' || c == 'U' || c == 'u') {
  32.                 Integer count = map.get(c);
  33.                 map.put(c, (count == null ? 1 : count + 1));
  34.                
  35.             }
  36.         }
  37.         System.out.println(map);
  38.     }
  39.        
  40.        
  41.        
  42.     }
  43.    
  44.  
  45.  

Replies to PD rss

Title Name Language When
Re: PD Łukasz java 6 Years ago.