Home About Contact Privacy Terms Disclaimer
TECHAntena
Last Updated On: September 18, 2017
Editor: Adeeb C

Java Program to Add Two Numbers

Category: Java
Tags

Are you searching for the Java program to add two numbers? Here is the program to add two numbers in Java.

Java Program to Add Two Numbers

In this java program, we are using two variables to store two numbers. And values are stored in the variables using the scanner method.

/* Java Program to Add two numbers*/
import java.util.Scanner;
public class JavaProgram
{
public static void main(String args[])
{
int x, y, sum;
Scanner scan = new Scanner(System.in);
System.out.print("Enter the Two Numbers : ");
x = scan.nextInt();
y = scan.nextInt();
sum = a + b;
System.out.print("Sum of these two numbers: " +sum);
}
}

If you have any doubts about this Java program to add two numbers, comment below.