0
Why this code is Giving error in sololearn compiler environment?
I have tried this code in my Eclipse and its executed successfully and giving the desired result. But sololearn compiler is giving Error for the whitespaces : IllegalArgumentException And for type conversion also.
6 Antworten
+ 2
https://code.sololearn.com/cm9bCt72ZzpR/?ref=app
this is your code . when we copy and paste the code extra space added in our code and solo learn read this spaces to character.
+ 1
when we copy and paste the code extra space added in our code and solo learn read this spaces to character.
0
Please share your code.
0
import java.util.Scanner;
public class Program
{
public static void main(String[] args) {
Scanner read=new Scanner(System.in);
try(read)
{
String inp=read.nextLine().trim();
String oup="";
int ascii=0;
for(int i=0;i<inp.length();i++)
{
char data=inp.charAt(i);
ascii=(int)data;
int ASCIIValue = ascii;
if (ASCIIValue >= 65 && ASCIIValue <= 90)
{
ASCIIValue = 65 - ASCIIValue + 122;
}
else if (ASCIIValue >= 97 && ASCIIValue <= 122)
{
ASCIIValue = 97 - ASCIIValue + 90;
}
else if (ASCIIValue >= 48 && ASCIIValue <= 57)
{
ASCIIValue = 48 - ASCIIValue + 57;
}
char c1 = (char)ASCIIValue;
oup = oup + c1;
}
System.out.println(oup.toLowerCase());
}
}
}
0
What was the problem?
0
Okay, thanks