package p07_funkcje;

import java.util.Scanner;

public class Palindrom {
	static boolean palindrom(String napis) {
		for(int left = 0, right = napis.length()-1; left < right; left++, right--) {
			if(napis.charAt(left) != napis.charAt(right)) {
				return false;
			}
		}
		return true;		
	}

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		System.out.println("Pusty tekst kończy program");
		while(true) {
			System.out.println("Podaj tekst:");
			String txt = scanner.nextLine();
			if(txt.isEmpty()) break;
			
			if(palindrom(txt)) {
				System.out.println("Tekst JEST palindromem");
			} else {
				System.out.println("Tekst NIE jest palindromem");
			}
		}
		System.out.println("Koniec");
	}

}
