Friday, February 9, 2007

SquareCube_Uservalues

class squarecube
{
public static void main(String a[])
{
int x,y,z;
x=Integer.parseInt(a[0]);
y=x*x;
z=x*x*x;
System.out.println(" Square of entered integer is "+y);
System.out.println(" Cube of entered integer is "+z);
}
}

Addition_Uservalues

class useradd
{
public static void main(String a[])
{
int x,y,z;
x=Integer.parseInt(a[0]);
y=Integer.parseInt(a[1]);
z=x+y;
System.out.println("THE SUM IS "+z);
}
}

Factorial Program

class factorial
{ public static void main(String a[])
{
int fact=1,i;
int d=Integer.parseInt(a[0]);
for(i=1;i<=d;i++)
fact=fact*i;
System.out.println("factorial="+fact);
}
}

Monday, January 29, 2007

Running a .java file

Lets know how to run a program written in java. For this you need to take the following steps:-
1) J.D.K(java development kit) which you can download from www.sun.com
2) Then go to 'command prompt(cmd)' from start>run>cmd
3) Then give the path wher you have installed J.D.K. and type
(edit , eg: edit demo.java)
4) Then type the program
5) Then type (javac , eg: javac demo.java)
6) If the program is executed successfully then type
(java , eg: java demo1)
------------------------------------------------------------------------------
Filename
------------------------------------------------------------------------------
class demo1
{
public static void main (String ar[])
{
System.out.println("Hello World");
}
}

Result:
Hello World
-------------------------------------------------------------------------------

Start



Java is the most powerfull Programming ever.

So lets learn some interesting java programs