+ 2
Why is it showing error????
import Java. until. Scanner; class abx { static boolean plain(String w) { int i; char x; String m=" "; for(i=w.length();i>0;i--) { x=w.charAt(i); m=m+x; } if(m==w) return true; else return false; } public static void main (String args[]) { Scanner sc=new Scanner(System.in); String s; String c=" "; int i, lo=0; char t; System. out. println("enter a sentence"); s=sc.nextLine(); for(i=0;i<s.length();i++) { t=s.charAt(i); if(t==' ') c=c+s.substring(lo,i+1); } if(plain(c) System. out.print(c); lo=i+1; } }
20 Respuestas
+ 2
You can chk my codes, and find easier ways to find a Palindrome
+ 2
Here is is :-
https://code.sololearn.com/cGDW6QhCimfl/?ref=app
+ 2
Anytime.
+ 1
I am not sure what your program aims to accomplish.
+ 1
Oh, you mean Palindrome, Lemme look at the code again
+ 1
This is a completely wrong code, it will not print anything except "enter a senetence"
0
import java.util.Scanner;
j is small, its util not until.
main(String args[]) , you missed ]
if(plain(c)) , you missed )
0
oh Ya... I've corrected it while making in computr but still it's showing error. thanks for this and tell more errors
0
error is
Java. Lang. StringIndexOutOfBoundsException:
String index out of range: 5(in Java. Lang.String)
what does it mean?????? 😁
0
I edited my previous message, chk it again
0
thanks...
I've corrected but still no result.
the same error as mentioned
0
It means that your string has length less than what you demand, thats why it runs out of bound.
0
so....
how to correct it????
tell plse
0
You need to do is,
for(i = w.length() - 1; i >= 0; i--)
at line 9, according to question.
0
thanks.. it has run but on typing an arms no. result is yet no one
why so
0
it's actually to find all Armstrong no. in a sentence.
like Ada, weew etc.
I downloaded this prog from net and ran it on computer
0
Sorry, I don't know whats an Armstrong number.
0
it is a word which is same from starting as well as end
eg-ere, ertyytre,
Anna etc
0
it's being download from net
am not getting what's actually is the error
0
all right...
thx
...