-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYT12.java
More file actions
40 lines (34 loc) · 1001 Bytes
/
YT12.java
File metadata and controls
40 lines (34 loc) · 1001 Bytes
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
/*Define a class to accept a string, convert it into lowercase & check whether the string is a pallindrome or not?
*A pallindrome is a word which reads the same backwards as forward.
*Example:
*Input String = MADAM
*Reverse String = MADAM
*/
import java.io.*;
class YT12
{
public static void main(String[] args)throws IOException
{
String str;
String str1="";
int L;
InputStreamReader I = new InputStreamReader(System.in);
BufferedReader br = new BufferedReader(I);
System.out.println("Enter the string: ");
str=br.readLine().toLowerCase();
L=str.length();
for(int i=L-1;i>=0;i--)
{
str1=str1+str.charAt(i);
}
System.out.println();
if(str.equals(str1))
{
System.out.println("RESULT: Pallindrome");
}
else
{
System.out.println("RESULT: Not Pallindrome");
}
}
}