Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Java program use of Scanner class, nextInt()

PROGRAM:


import java.util.Scanner;


public class AddNumbers {
public static void main(String args[])
{
int x,y,z;

System.out.println(“Enter 2 integers to calculate sum”);
Scanner in = new Scanner(System.in);

x = in.nextInt();
y = in.nextInt();
z=x+y;
System.out.println(“Sum of integers =” +z);


}
}


OUTPUT:


Enter 2 integers to calculate sum
45
52
Sum of integers =97