package javaapplication7;
import java.util.Scanner;
public class JavaApplication7 {
public static
void main (String[] args) {
Scanner input
= new Scanner(System.in);
String a;
int d=0;
int f=0;
System.out.print("Masukkan kata : ");
a =
input.next();
for (int i = a.length(); i >0 ; i--) {
String c = a.substring(i-1, i);
d=d+1;
String e = a.substring(d-1, d);
if(c.equals(e))
{
f+=1;
}
}
if(f==a.length()){
System.out.println("Kata "+a+"
merupakan Palindrome");}
else{
System.out.println("Kata "+a+" bukan
Palindrome");}
}
}
0 komentar:
Posting Komentar