Advertisement
Guest User

Untitled

a guest
May 25th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.67 KB | None | 0 0
  1. package com.company;
  2.  
  3. import com.sun.org.apache.xpath.internal.SourceTree;
  4.  
  5. import javax.sound.midi.Soundbank;
  6. import java.io.PrintStream;
  7. import java.util.Arrays;
  8. import java.util.Scanner;
  9.  
  10. public class Main {
  11.  
  12.     public static void main(String[] args) {
  13.  
  14.        
  15.  
  16.  
  17.  
  18.  
  19.  
  20.  
  21.  
  22.  
  23.  
  24.  
  25.  
  26.  
  27.  
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37.         /* System.out.println("Program sprawdza czy podane slowo jest palindromem.\nWpisz slowo do sprawdzenia: ");
  38.         Scanner p = new Scanner(System.in);
  39.         String palindrom = p.nextLine();
  40.         char [] palChar = palindrom.toCharArray();
  41.         int start=0;
  42.         char temp;
  43.         int end=palindrom.length() -1;
  44.         while(end>start){
  45.             temp = palChar[start];
  46.             palChar[start] = palChar[end];
  47.             palChar[end] = temp;
  48.             start++;
  49.             end--;
  50.         }
  51.         String palString = new String(palChar);
  52.         System.out.printf("Slowo od konca to: %s\n", palString);
  53.         if(palindrom.equals(palString)){
  54.             System.out.printf("Podane slowo to palindrom.\n%s = %s", palindrom, palString);
  55.         }else{System.out.println("Podane slowo nie jest palindromem.");
  56.  
  57.  
  58.         //Program liczy ilosc samoglosek w slowie/zdaniu.
  59.  
  60.         System.out.println("Program liczy ilosc samoglosek w zdaniu oraz wypisuje ile razy kazda zostala powtorzona.\nWpisz dowolny tekst: \n");
  61.         Scanner s = new Scanner(System.in);
  62.         String text = s.nextLine();
  63.         char [] textChar = text.toCharArray();
  64.         int start=0;
  65.         int end=text.length();
  66.         char temp;
  67.  
  68.         //jesli samogloska
  69.         int vowel = 0;
  70.         int a=0;
  71.         int e=0;
  72.         int o=0;
  73.         int u=0;
  74.         int i=0;
  75.         int y=0;
  76.         while(start<end){
  77.             temp = textChar[start];
  78.             if(temp=='a'){
  79.             vowel++;
  80.             a++;
  81.             }
  82.             else if( temp=='e'){
  83.                 vowel++;
  84.                 e++;
  85.             }
  86.             else if ( temp=='o'){
  87.                 vowel++;
  88.                 o++;
  89.             }
  90.             else if(temp=='u'){
  91.                 vowel++;
  92.                 u++;
  93.             }
  94.             else if(temp=='i'){
  95.                 vowel++;
  96.                 i++;
  97.             } else if (temp == 'y') {
  98.                 vowel++;
  99.                 y++;
  100.             }
  101.             start++;
  102.         }
  103.         System.out.printf("Liczba samoglosek wynosi:\n ogolem: %d%n \na: %d%n\ne: %d%n\no: %d%n\nu: %d%n\ni: %d%n\ny: %d%n", vowel, a, e, o, u, i, y);
  104.        // System.out.printf("\na: %d%n\ne: %d%n\nu: %d%n\ni: %d%n\ny: %d%n", vowel,a,e,o,u,i,y);
  105.  
  106.  
  107.  
  108.  
  109. */
  110.  
  111.       /*  System.out.println("Program wypisuje litery w odwrotnej kolejnosci.\nCzy chcesz kontynuowac?");
  112.         Scanner s = new Scanner(System.in);
  113.         String choice = s.nextLine();
  114.         while (!(choice.equals("x") || choice.equals("X"))) {
  115.  
  116.         //user input
  117.         System.out.println("Wpisz dowolne slowo:    ");
  118.         Scanner userInputScanner = new Scanner(System.in);
  119.         String userInput = userInputScanner.nextLine();
  120.         System.out.println("Twoje slowo to: " + userInput);
  121.         System.out.println("Ilosc znakow w Twoim slowie wynosi: " + userInput.length());
  122.         choice = userInput;
  123.         char [] in = userInput.toCharArray();
  124.         int begin = 0;
  125.         int end = in.length - 1;
  126.         char temp;
  127.         while(end>begin){
  128.             temp = in[begin];
  129.             in[begin] = in[end];
  130.             in[end] = temp;
  131.             end--;
  132.             begin++;
  133.  
  134.             }
  135.             String array = new String(in);
  136.             System.out.printf("Twoj wyraz od konca to: %s \n\n",  array);
  137.         }*/
  138.     }
  139. }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement