Showing posts with label Basic programs of java. Show all posts
Showing posts with label Basic programs of java. Show all posts

Sunday, 22 September 2013

Multiplication of two numbers.

PROGRAM CODING:

class Multiplication
{
public static void main(String args[])
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c;
c=a*b;
System.out.println("The Multiplication of two value is"+c);
}
}

OUTPUT:

C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>javac Multiplication.java
C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>jfava Multiplication 10 6
The Multiplication of two value is 60

Difference between two numbers

PROGRAM CODING:

class Subtraction
{
public static void main(String args[])
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c;
c=a-b;
System.out.println("The Difference between two value is"+c);
}
}

OUTPUT:

C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>javac Subtraction.java
C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>java Subtraction 10 8
The Difference between two value is 2

Addition of two numbers


PROGRAM CODING:

class Addition
{
public static void main(String args[])
{
int a=Integer.parseInt(args[0]);
int b=Integer.parseInt(args[1]);
int c;
c=a+b;
System.out.println("The addition of two value is"+c);
}
}

OUTPUT:


C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>javac Addition.java
C:\Program Files (x86)\Java\jdk1.7.0_25\bin\Lokey>java Addition 5 6
The addition of two value is 11.

Tuesday, 10 September 2013

how to find the IP Address of your system

From the program given bellow you can able to find the IP Address of your system..Check this out...


Program coding:


import java.net.InetAddress;

class IPAddress
{
   public static void main(String args[]) throws Exception
   {
      System.out.println(InetAddress.getLocalHost());
   }
}

Output:

122.164.255.215