Monday, August 4, 2014

How to add two number in java by keyboard

How to add two number in  java by keyboard
   import java.util.*;
   public class Add
    {
    public static void main(String args[])
    {
       int a,b;
    Scanner sc=new Scanner(System.in);
    System.out.println("Enter two number");
    a=sc.nextInt();
    b=sc.nextInt();
    c=a+b;
   System.out.println("The Sum of two number is  "+c);
   }
}

output:
   Entre two number
10
20
 The Sum of two number is  30
  here we are use the scanner class for taking the input by keyboard.

No comments:

Post a Comment

Featured Post

What is JavaScript? What is the role of JavaScript engine?

  The JavaScript is a Programming language that is used for converting static web pages to interactive and dynamic web pages. A JavaScript e...