User input | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

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

15th Sep 2021, 7:00 PM
Mario
5 Answers
+ 2
Mario , please post your code here. thanks!
15th Sep 2021, 7:16 PM
Lothar
Lothar - avatar
+ 1
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.
15th Sep 2021, 7:56 PM
Lisa
Lisa - avatar
0
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?
15th Sep 2021, 7:11 PM
Lisa
Lisa - avatar
0
import java.util.Scanner; class Easy { public static void main(String[] args) { Scanner Scanner obj=new Scanner(System.in); 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); } }
15th Sep 2021, 7:47 PM
Mario
0
Okay, I'll try. Thanks
15th Sep 2021, 8:17 PM
Mario