Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Palindromo {
- public static void main(String[] args) {
- System.out.printf("Escreva: ");
- Scanner x = new Scanner(System.in);
- String frase = x.nextLine();
- String novafrase = frase.replaceAll(" ", "").toUpperCase();
- StringBuffer sb = new StringBuffer(novafrase);
- sb = sb.reverse();
- if (novafrase.equals(sb.toString()))
- System.out.println(frase+" é palíndromo");
- else
- System.out.println(frase+" não é palíndromo");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement