Advertisement
Guest User

Book

a guest
Nov 24th, 2014
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.45 KB | None | 0 0
  1. /*******************************************************************************
  2.  * Kožusznik Jan
  3.  * Copyright (c) 2014 All Right Reserved, http://www.kozusznik.cz
  4.  *
  5.  * This file is subject to the terms and conditions defined in
  6.  * file 'LICENSE.txt', which is part of this source code package.
  7.  ******************************************************************************/
  8.  
  9. package $007_string_processing;
  10.  
  11. import java.util.ArrayList;
  12. import java.util.Iterator;
  13. import java.util.List;
  14.  
  15. /**
  16.  * @author Jan Kožusznik
  17.  * @version 0.1
  18.  */
  19. public class Run07 {
  20.  
  21.   public static void main(String[] args) {
  22.      
  23.       Book b1 = new Book();
  24.      
  25.       String text = b1.toString();
  26.       int counter = 0;
  27.       for (int i = 0; i < text.length(); i++) {
  28.           char pismeno = text.charAt(i);
  29.           if(pismeno == 'a'){
  30.               counter++;
  31.           }
  32.       }
  33.       System.out.println(counter);
  34.      
  35.       int counter2 = 0;
  36.       String text2 = text.toLowerCase();
  37.       for(int i=0; i < text2.length(); i++){
  38.           char pismeno2 = text2.charAt(i);
  39.           if("aeiyou".indexOf(pismeno2) != -1){
  40.               counter2++;
  41.           }
  42.       }
  43.       System.out.println(counter2);
  44.      
  45.       System.out.println(text2.indexOf("stařec", 10));
  46.      
  47.       int counter3 = 0;
  48.       int lastindex = 0;
  49.      
  50.       while(lastindex != -1){
  51.          
  52.           lastindex = text2.indexOf("stařec",lastindex);
  53.          
  54.           if(lastindex != -1){
  55.               counter3++;
  56.               lastindex+=1;
  57.           }
  58.      
  59.       }
  60.      
  61.       System.out.println(counter3);
  62.      
  63.   }
  64.  
  65. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement