The Scanner class is used to get user input, and it is found in the java.util package. To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation.
Program:-
package payilagam.institution;
import java.util.Scanner;
public class Three {
public static void main(String[] args)
{
Scanner sc=new Scanner(System.in);
System.out.println("Enter the two numbers");
int a = sc.nextInt();
int b = sc.nextInt();
System.out.println("The addition is " + (a+b));
}
}
Output Screenshot:-
