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);
}
}
The only blog for java programs and college assignments
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);
}
}
at
9:49 AM
0
comments
Posted by
Maunil K.G.
Labels: SquareCube_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);
}
}
at
9:43 AM
0
comments
Posted by
Maunil K.G.
Labels: Addition Uservalues
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);
}
}
at
9:35 AM
0
comments
Posted by
Maunil K.G.
Labels: Factorial Program
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
4) Then type the program
5) Then type (javac
6) If the program is executed successfully then type
(java
------------------------------------------------------------------------------
Filename
------------------------------------------------------------------------------
class demo1
{
public static void main (String ar[])
{
System.out.println("Hello World");
}
}
Result:
Hello World
-------------------------------------------------------------------------------
at
7:12 AM
0
comments
Posted by
Maunil K.G.