0

Could someone explain me why my code doesn't pass the tests of sololearn ??? How should I build my solutions ?

import java.util.List; import java.util.ArrayList; public class Program { public static void main(String[] args) { descryptor ("s@ocat@@"); } public static void descryptor (String input){ char [] arrInp =input.toCharArray(); List <Character> box=new ArrayList <>(); int len=arrInp.length-1 ; int count =0; for(int k=len;k>=0;k--){ if(Character.isLetter(arrInp [k])|| arrInp[k]==' '){ box.add(arrInp[k]); count ++; } } char[] dest=new char[box.size()]; for(int i=0;i<dest.length; i++){ dest[i]=box.get(i); } String out=new String(dest); System .out .println (out); } }

18th Oct 2020, 4:27 PM
Vasyl
Vasyl - avatar
12 ответов
+ 2
Could u plzz put the link to it
18th Oct 2020, 4:35 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
What is the test description? Is there need only for one input for which you passed to method..?
18th Oct 2020, 4:39 PM
Jayakrishna 🇮🇳
+ 1
No, there are 5 different values for input and I just don't understand how testing system put them to my code
18th Oct 2020, 4:44 PM
Vasyl
Vasyl - avatar
+ 1
Oh okay u need to use the Scanner
18th Oct 2020, 4:45 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
This is The Spy life task
18th Oct 2020, 4:45 PM
Vasyl
Vasyl - avatar
+ 1
Vasyl as I told you use the Scanner. So to input the values.
18th Oct 2020, 4:46 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
First you have to import the Scanner class, import java.util.Scanner
18th Oct 2020, 4:49 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
And after you write the line you just commented with, don't forget to do the in.nextline() or in.next() or nextInt.....depends on the type of your inputs
18th Oct 2020, 4:51 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
Vasyl no problem
18th Oct 2020, 5:00 PM
Khaled ^^ خالد القريشي‎
Khaled ^^ خالد القريشي‎ - avatar
+ 1
It's not passing the specific requirements.
19th Oct 2020, 9:25 PM
Sonic
Sonic - avatar
0
So just type Scanner in=new Scanner(); in the method main ???
18th Oct 2020, 4:47 PM
Vasyl
Vasyl - avatar
0
Thanks for help )
18th Oct 2020, 4:59 PM
Vasyl
Vasyl - avatar