Wednesday 27 July 2016

write a program in java to addition of two number

write a program in java to addition of two number

  1. import java.io.*;
  2. class Addition
  3. {
  4. public static void main(String args[])throws Exception
  5. {
  6. int a,b,c;
  7. BufferedReader br= new BufferedReader( new InputStreamReader(System.in));
  8. System.out.println("Enter the two numbers to add:");
  9. a=Integer.parseInt(br.readLine());
  10. b=Integer.parseInt(br.readLine());
  11. c = a+b;
  12. System.out.println("\nSum of two numbers:"+ c);
  13. }
  14. }


After run this program we will get output like this:

Output:
Enter the two numbers to add:
2
3
Sum of two numbers:5

No comments:

Post a Comment