Featured Post

Wednesday, May 10, 2017

java program to add two numbers using Scanner class



import java.util.Scanner;
class interactiveio   /* interactiveio.java*/
{
   public static void main(String args[])
   {
      Scanner s=new Scanner(System.in);
      System.out.println("enter any two numbers");
      int a=s.nextInt();
      int b=s.nextInt();
      int c=a+b;
      System.out.println("addition of and b is "+c);
    }
}

D:\cjuschools>javac interactiveio.java
D:\cjuschools>java interactiveio
enter any two numbes
12
13
addition of a and b is 25

/*keynotes: Scanner class is used to take input from the keyboard*/
/*System.in stands for keyboard*/
/*What ever input is given from the keyboard is taken as string value*/
/* string value will be converted to integer value using wrapper class method(using nextInt())*/





oops through java,inheritance,interface,package,super keyword, program demonstrating the use of super keywork,abstract class,static,main,awt,swings,jtab,layout,panel,applet,param,Frame,JFrame, swingutilities.invokeLater,swingutilities.invokeanwait,multithreading,multiprocesing,start(),init() paint(),adapter class,inner class,annonymous inner class,outer class,packages,friendly, constrcutors,destructors,garbage collector,inheritance,encapusulation,abstraction, bytecode, compiler,interpreter,jdbc,jsp pages,exception handling

No comments:

Post a Comment