+ 2
How can I assign 2 integer values(which user entered) to 2 different variables?
How can I assign 2 integers, which user inputs, to 2 different variables? for example: user has entered: 2 and 3. how can I type int x = "number that user entered first" and int y "number that user entered second" I dont know how clear is my question, but I hope that you will get what I mean. :)
2 Answers
+ 30
import java.util.Scanner;
public class Program{
public static void main(String[] args){
Scanner sc=new Scanner(System.in);
int x=sc.nextInt(),y=sc.nextInt();
System.out.print(x+" is the first number entered\n"+y+" is second number entered");
}
}
//hope it helpsâș
+ 2
Thanks a lot, it worked! đ