+ 2

Why this code is not working?

according to m https://code.sololearn.com/cmTq7A0r08DW/?ref=app

21st Dec 2017, 12:09 PM
Neelansh Parashar
Neelansh Parashar - avatar
4 Answers
+ 5
1. import not Import 2. System.in not system.in 3. You are trying to compare uage(Scanner type) with 18(int) it will not work. I changed it to show the algorithm need to be done. In this case you need to cast user input to string than to int https://code.sololearn.com/cFy00DW7d496/?ref=app
21st Dec 2017, 12:25 PM
Dima Makieiev
Dima Makieiev - avatar
+ 4
Look like you are currently correcting it, continue! Just remember that Scanner return your value with getInt so you have to store it! You only print it. You also compare directly integer with Scanner objet but you want instead compare it to your stored value! Good luck and be carefull with lower case letters ! (Import, system, next int, etc )
21st Dec 2017, 12:35 PM
Kabe
+ 3
I totally forget that scanner can return int :)
21st Dec 2017, 12:53 PM
Dima Makieiev
Dima Makieiev - avatar
+ 2
never mind, your answer was really helpful.â˜ș
21st Dec 2017, 1:22 PM
Neelansh Parashar
Neelansh Parashar - avatar