Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class BackWordsString {
- /**
- * @ConnorSiebens
- */
- public static void main(String[] args) {
- Scanner keyboard = new Scanner(System.in);
- String word,back="";
- System.out.println("Enter a word to be printed backwards.");
- word = keyboard.nextLine();
- for(int i=word.length();i>0;i--) {
- back += word.charAt(i-1);
- }
- System.out.println(back);
- if(back.compareToIgnoreCase(word)==0) {
- System.out.println("It's a palindrome.");
- }
- keyboard.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement