Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок0
How to solve illegal character in Scanner issue. Inputs are integers
Code on computer works perfect but here on phone Its saying illegal character. I think its '\n' but inputs are with integers. import java.util.*; public class Program{ public static void main(String[] args) { Scanner sc = new Scanner(System.in); ArrayList<Integer> arr = new ArrayList<Integer>(); for(int i = 0; i < 6; i++){ arr.add(sc.nextInt()); } for(int i = 0; i < arr.size(); i++){ if(arr.get(i) % 3 == 0){ System.out.print("Pop "); }else if(arr.get(i) % 2 == 0){ System.out.print("Cracle "); }else if(arr.get(i) % 3 != 0 && arr.get(i) % 2 != 0 ){ System.out.print("Snap "); } } } }
10 ответов
+ 3
Check again :)
import java.util.*;
public class Program{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
ArrayList<Integer> arr = new ArrayList<Integer>();
for(int i = 0; i < 6; i++){
arr.add(sc.nextInt());
}
for(int i = 0; i < arr.size(); i++){
if(arr.get(i) % 3 == 0){
System.out.print("Pop ");
}
else if(arr.get(i) % 2 == 0){
System.out.print("Cracle ");
}
else if(arr.get(i) % 3 != 0 && arr.get(i) % 2 != 0 ){
System.out.print("Snap ");
}
}
}
}
+ 2
Try writing the whole code again on sololearn code playground. This occurs because you must have copy pasted the code from your computer.
+ 2
You said that you did "on your computer " then you must have copy-pasted the snippet thats why illegal chars
edit®Marko Bitenc I only removed those, rest of you code is intact 👍
+ 2
I have just realized that it was a code-coach problem, for that you have to check spellings and while importing avoid using * only import what is necessary
//same for DM, I edited my last answer for that :)
+ 1
No i did it first here then on my computer to see what is going on.
+ 1
Yes works :) thanku you. ok where was issue?
+ 1
Thank you
0
But i will rewrite it again and see if works anyway
0
No, first i made here like i always do. It happen some time as i delete something and proceed
- 1
queen_h94