Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
palin
//'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_111 import java.util.*; class palin { int l,c=0; String s,w="",t=""; char ch,ch1; void run() { Scanner sc=new Scanner(System.in); System.out.println("enter the sentence"); s=sc.nextLine(); l=s.length(); ch=s.charAt(l-1); if(ch!='.'&& ch!='?'&& ch!='!') { System.out.println("invalid input"); } else { for(int i=0;i<l;i++) { ch1=s.charAt(i); if(ch==' ' || ch=='?'|| ch=='!' || ch== '.') { if(w.equals(t)) { System.out.println(w+" "); c++; } w="";t=""; } else { w=w+ch; t=ch+t; } } } System.out.println("the no. of palindromic words is"+c); }}
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
3c
assign
JAVA # Klavyeden girilen cümlede kaç adet "a" harfi var
Huffman Encoding Tree v2
2darray
Bubble Sort
Escaping Literals (Table of records)
Compare Version Numbers
Parse and flatten string
vampires number Eckel B. Thinking in Java
stackse - search stackoverflow differently
Please log in to post a comment.