-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPalindromeProgram.java
More file actions
52 lines (39 loc) · 1.3 KB
/
PalindromeProgram.java
File metadata and controls
52 lines (39 loc) · 1.3 KB
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package com.lftechnology.programs;
import java.util.Scanner;
public class PalindromeProgram {
private String number;
private Scanner scanner;
public PalindromeProgram() {
}
public void run() {
this.initiateRun();
System.out.println("->Please Enter the Number of Multiplier");
scanner = new Scanner(System.in);
this.number = scanner.nextLine();
Boolean isPalindrome = this.isPalindrome();
if (isPalindrome == true) {
System.out.println("The number is a palindrome number");
} else {
System.out.println("The number is not a palindrome number");
}
this.endRun();
}
public Boolean isPalindrome() {
String reverse = "";
int length = this.number.length();
for (int i = length - 1; i >= 0; i--)
reverse = reverse + this.number.charAt(i);
if (this.number.equals(reverse))
return true;
else
return false;
}
public void initiateRun() {
System.out.println("\n");
System.out.println("->Executing Palindrome Program");
}
public void endRun() {
System.out.println("-----------------------------------------");
System.out.println("-----------------------------------------\n\n");
}
}