Written by Sai Sandeep Thota on June 29, 2013 in Java > Programming

Java Program to Add two Numbers

GET ALERTS:

Get our Latest updates delivered to your mailbox!

In this article we are going to write a Java program to Add two Numbers. We are using three variables in this program, they are: a, b, sum. Variables a and b will take the values given as input by the user and sum variable will store the sum value of a two numbers.

Java Program to Add two Numbers

import java.util.Scanner;
class AddNum {
	public static void main(String args[])
	{
		int a, b, sum;
		System.out.println("Enter two Numbers:");
		Scanner get = new Scanner(System.in);
		a = get.nextInt();
		b = get.nextInt();
		sum = a + b;
		System.out.println("Sum of "+a+" + "+b+" = "  +sum);
	}
}

Output:
Java Program to Add Two Numbers

{ 0 comments… add one now }

Leave a Comment

Previous post:

Next post: