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

Java Scanner progam

PROGRAM:

Simple program to show use of scanner class.

import java.util.Scanner;

public class AddScanner {

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
54
45
Sum of integers =99