Java Addition through user input


Addition through user input value

In this program, you’ll learn to store and add two integer numbers in Java. After addition, the final sum is displayed on the screen.

Source code

import java.io.*;
import java.util.*;
class Add
{
public static void main(String[] args)
{
Scanner ob=new Scanner(System.in);
System.out.println(“enter value of a and b”);
int x,y;
x=ob.nextInt();
y=ob.nextInt();
int z=x+y;
System.out.println(“sum of Z:”+z);
}
}

Have any Question or Comment?

Leave a Reply

Your email address will not be published. Required fields are marked *

Categories