-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpallindrome_sentence_word.java
52 lines (51 loc) · 1.08 KB
/
pallindrome_sentence_word.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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
/**
* Write a description of class pallindrome_sentence_word here.
*
* @author (Debdut Goswami)
* @version (3.1.5)
*/
import java.io.*;
public class pallindrome_sentence_word
{
public static void main(String args[])throws IOException
{
InputStreamReader read =new InputStreamReader(System.in);
BufferedReader in=new BufferedReader(read);
System.out.println("Enter the sentence?");
String str=in.readLine();
str=str+" ";
String pall=" ";
String o=" ";
int l=str.length();
for(int i=0;i<l;i++)
{
char ch=str.charAt(i);
if(ch=='.')
{
str=str.replace(ch,' ');
}
}
for(int i=0;i<l;i++)
{
if(str.charAt(i)==' ')
{
pall=pall.toLowerCase();
o=o.toLowerCase();
System.out.println(pall+" "+o);
boolean p=pall.equalsIgnoreCase(o);
System.out.println(p);
if(o.compareTo (pall)==0)
{
System.out.println(pall);
}
pall=" ";
o=" ";
}
else
{
pall=str.charAt(i)+pall;
o=o+str.charAt(i);
}
}
}
}