Advertisement
ConnorSiebens

BackWordsString

Dec 13th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.51 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class BackWordsString {
  3.     /**
  4.      * @ConnorSiebens
  5.      */
  6.     public static void main(String[] args) {
  7.         Scanner keyboard = new Scanner(System.in);
  8.         String word,back="";
  9.         System.out.println("Enter a word to be printed backwards.");
  10.         word = keyboard.nextLine();
  11.         for(int i=word.length();i>0;i--) {
  12.             back += word.charAt(i-1);
  13.         }
  14.         System.out.println(back);
  15.         if(back.compareToIgnoreCase(word)==0) {
  16.             System.out.println("It's a palindrome.");
  17.         }
  18.         keyboard.close();
  19.     }
  20.  
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement