Advertisement
Guest User

LetrasMaiusculas

a guest
Jun 27th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Palindromo {
  4.     public static void main(String[] args) {
  5.         System.out.printf("Escreva: ");
  6.         Scanner x = new Scanner(System.in);
  7.         String frase = x.nextLine();
  8.         String novafrase = frase.replaceAll(" ", "").toUpperCase();
  9.         StringBuffer sb = new StringBuffer(novafrase);
  10.         sb = sb.reverse();
  11.         if (novafrase.equals(sb.toString()))
  12.             System.out.println(frase+" é palíndromo");
  13.         else
  14.             System.out.println(frase+" não é palíndromo");
  15.     }
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement