Saturday, 19 March 2016

simple addition



import java.io.*;
class add
{
public static void main(String args[])throws IOException
{
DataInputStream s = new DataInputStream(System.in);
int a,b,c;

System.out.println("Enter the first number");
a=Integer.parseInt(s.readLine());
System.out.println("Enter the Second number");
b=Integer.parseInt(s.readLine());
c=a+b;
System.out.println("Sum of two numbers is "+c);
}
}


OUTPUT:

H:\>path=C:\jdk1.3\bin;

H:\>javac add.java
Note: add.java uses or overrides a deprecated API.
Note: Recompile with -deprecation for details.

H:\>java add
Enter the first number
25
Enter the Second number
30
Sum of two numbers is 55






No comments:

Post a Comment