repl.it
@CarterMonkey/

JavaCoderGames

Java

No description

fork
loading
Files
  • Main.java
Main.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
class Main {
  public static void main(String[] args) {
    Scanner in= new Scanner(System.in);
    System.out.println("Enter your word: ");
    String word=in.next();
    int x = word.length();
    int l = word.length();
    char [] letters = new char[x];
    for (int i=0; i<x; i++) {
      letters[i]=word.charAt(i);

    }
    int b=1;
    for (int j=x-1; j>=0 ;j--) {
      System.out.print(letters[j]);
      for (int k = 0; k<l; k++) {
        if (word.charAt(j)==word.charAt(k)) {
          b++;
        }
      }
    if (b==l) {
      System.out.println("That word is a palindrome! ");
    
    }
    }

  }
}