Sum Of Two Numbers

Sum of two integer number:
/* Addition of two integer */
//programming789.blogspot.com
import java.util.Scanner;
class AddNumbers
{
   public static void main(String args[])
   {
      int a, b, c;
      Scanner in = new Scanner(System.in);       
      System.out.println("Enter 1st no:");
      a = in.nextInt();
      System.out.println("Enter 2st no:");
      b = in.nextInt();
      c = a + b;
      System.out.println("Sum of entered integers = "+c);
   }
}
● Open notepad and add the code.
● Save the file as AddNumbers.java.
● When the program is run, the following output is displayed:

















● Enter the integer value at time of give input.
If you want to add two floating point number add following code:

/* Addition of two float number*/

import java.util.Scanner;
class AddNumbers
{
   public static void main(String args[])
   {
      float a, b, c;
      Scanner in = new Scanner(System.in);       
      System.out.println("Enter 1st no:");
      a = in.nextFloat();
      System.out.println("Enter 2st no:");
      b = in.nextFloat();
      c = a + b;
      System.out.println("Sum of entered integers = "+c);
   }
}