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 ");        }    } } }

22nd Apr 2020, 12:53 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
10 Respostas
+ 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 "); } } } }
22nd Apr 2020, 1:18 PM
Daljeet Singh
Daljeet Singh - avatar
+ 2
Try writing the whole code again on sololearn code playground. This occurs because you must have copy pasted the code from your computer.
22nd Apr 2020, 1:02 PM
Avinesh
Avinesh - avatar
+ 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 👍
22nd Apr 2020, 2:26 PM
Daljeet Singh
Daljeet Singh - avatar
+ 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 :)
25th Apr 2020, 3:20 PM
Daljeet Singh
Daljeet Singh - avatar
+ 1
No i did it first here then on my computer to see what is going on.
22nd Apr 2020, 1:05 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
+ 1
Yes works :) thanku you. ok where was issue?
22nd Apr 2020, 1:26 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
+ 1
Thank you
25th Apr 2020, 3:21 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
0
But i will rewrite it again and see if works anyway
22nd Apr 2020, 1:07 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
0
No, first i made here like i always do. It happen some time as i delete something and proceed
22nd Apr 2020, 2:30 PM
🔹Marko B.🔹
🔹Marko B.🔹 - avatar
- 1
queen_h94
3rd Jun 2022, 11:25 AM
Um Thamer