Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.company;
- import com.sun.org.apache.xpath.internal.SourceTree;
- import javax.sound.midi.Soundbank;
- import java.io.PrintStream;
- import java.util.Arrays;
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- /* System.out.println("Program sprawdza czy podane slowo jest palindromem.\nWpisz slowo do sprawdzenia: ");
- Scanner p = new Scanner(System.in);
- String palindrom = p.nextLine();
- char [] palChar = palindrom.toCharArray();
- int start=0;
- char temp;
- int end=palindrom.length() -1;
- while(end>start){
- temp = palChar[start];
- palChar[start] = palChar[end];
- palChar[end] = temp;
- start++;
- end--;
- }
- String palString = new String(palChar);
- System.out.printf("Slowo od konca to: %s\n", palString);
- if(palindrom.equals(palString)){
- System.out.printf("Podane slowo to palindrom.\n%s = %s", palindrom, palString);
- }else{System.out.println("Podane slowo nie jest palindromem.");
- //Program liczy ilosc samoglosek w slowie/zdaniu.
- System.out.println("Program liczy ilosc samoglosek w zdaniu oraz wypisuje ile razy kazda zostala powtorzona.\nWpisz dowolny tekst: \n");
- Scanner s = new Scanner(System.in);
- String text = s.nextLine();
- char [] textChar = text.toCharArray();
- int start=0;
- int end=text.length();
- char temp;
- //jesli samogloska
- int vowel = 0;
- int a=0;
- int e=0;
- int o=0;
- int u=0;
- int i=0;
- int y=0;
- while(start<end){
- temp = textChar[start];
- if(temp=='a'){
- vowel++;
- a++;
- }
- else if( temp=='e'){
- vowel++;
- e++;
- }
- else if ( temp=='o'){
- vowel++;
- o++;
- }
- else if(temp=='u'){
- vowel++;
- u++;
- }
- else if(temp=='i'){
- vowel++;
- i++;
- } else if (temp == 'y') {
- vowel++;
- y++;
- }
- start++;
- }
- 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);
- // 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);
- */
- /* System.out.println("Program wypisuje litery w odwrotnej kolejnosci.\nCzy chcesz kontynuowac?");
- Scanner s = new Scanner(System.in);
- String choice = s.nextLine();
- while (!(choice.equals("x") || choice.equals("X"))) {
- //user input
- System.out.println("Wpisz dowolne slowo: ");
- Scanner userInputScanner = new Scanner(System.in);
- String userInput = userInputScanner.nextLine();
- System.out.println("Twoje slowo to: " + userInput);
- System.out.println("Ilosc znakow w Twoim slowie wynosi: " + userInput.length());
- choice = userInput;
- char [] in = userInput.toCharArray();
- int begin = 0;
- int end = in.length - 1;
- char temp;
- while(end>begin){
- temp = in[begin];
- in[begin] = in[end];
- in[end] = temp;
- end--;
- begin++;
- }
- String array = new String(in);
- System.out.printf("Twoj wyraz od konca to: %s \n\n", array);
- }*/
- }
- }}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement