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
5 Respuestas
+ 2
Mario ,
please post your code here.
thanks!
+ 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.
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?
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);
}
}
0
Okay, I'll try.
Thanks