User input | Sololearn: Learn to code for FREE!


User input

Hi, I subscribed for one month, but can't get input from the user. I'm learning java programming and I've been used "import java.util.Scanner;" for getting input from the user, however it's not working. I'm using "Sololearn app". Could someone tell me what I should do in order to get input from the user, please? Kind regards, Mario


9/15/2021 7:00:10 PM


5 Answers

New Answer


Mario , please post your code here. thanks!


Apart from that you have 2 Scanner keywords when instantiating the scanner, your code works. On sololearn you have to provide all 3 inputs at once: When the input window opens you have to provide all 3, separated by line break.


Is it only in your own code not working? Or also in the example codes in the tutorial? Can you given an example in which code it isn't working?


import java.util.Scanner; class Easy { public static void main(String[] args) { Scanner Scanner obj=new Scanner(; String name; int rollno; float marks; System.out.println("Enter your name"); name=obj.nextLine(); System.out.println("Enter your rollno"); rollno=obj.nextInt(); System.out.println("Enter your marks"); marks=obj.nextFloat(); System.out.println("Name="+name); System.out.println("Rollno="+rollno); System.out.println("Marks="+marks); } }


Okay, I'll try. Thanks