Wednesday, 27 July 2011

Simple program for printing the following chatuskon upto given value and print the patter for “*”



                        *
                                                                                                    *                  *                  *                                                                                                 
                                                                                *                  *                  *                  *                  *
                                                            *                  *                  *                  *                  *                  *                  *
                                        *                  *                  *                  *                  *                  *                  *                  *                  *




class a1

{

Public static void main (String args[])

{

int I,j,k,1;

for(i=1;i<=5;i++)

{

for(1=5;1>=I;1--)

System.out.print(“\t”)

for(j=1:j<=I;j++)

System.out.print(“*\t”);

for(k=i-1;k=1;k--)

System.out.print(“*\t”);

System.out.println();
}
}









simple program for printing the following pyramid using for loop



                                                            1                  2                 1
                                       1                  2                 3                 2                 1
       1                  2                 3                 4                 3                 2                 1
1                 2                 3                 4                 5                 4                 3                 2                 1




class a

{

Public static void main(String args[])

{

int I,j,k,l;
for(i=1; i<=5;i++)

{

for(i=5;1>=I;1--)

System.out.printl(“\t”)

for(j=1;j<=I;j++)

System.out.println(J+”\t”);

for(k=i-1;k=1;k--)

System.out.print(k+”\t”);

System.out.println( );

}

}

Program for Printing the following pyramid



1
2 2
3 3 3
4 4 4 4
n n n ………………n

class series
{

Public static void main (String args[])
{

int i,j,n;
n=50;

for(i=1;i<=50; i++ )

{

for(j=1;j<=1;j++)

{

system.out.print (i);

}

system.out.println (“ “);

}
}
}

Simple program for making Pyramid using only while loop


1
1 2
1 2 3
1 2 3 4
1 2 3 4…..N

class series
{

Public static void main (String args [])

{

int N=10; i=1; j=1;
while( i<N)

{

j=1;
while(J<=i)

{

System.out.println(j);
J++;

}

System.out.println(“”);
i++;

}
}
}








Program to find the greater number from the three nos. using nested if else statement


Classs max
{
             Public static void main (String args[]) 

             {

Int a,b,c;
A=25; b=30; c=10;
if(a>b)

             {

if(a<c)

System.out.println(“a is maximum”);

else

System.out.println(“c is maximum”);

}
else

if(b>c)

System.out.printl(“b is maximum”);

else

System.out.printl(“c is maximum”);
}
               }

}

A simple program for addition of two values:



Class addition
{
Public static void main (String args[])
   {
int a = 5, b=10;
int c= a+ b;

System.out.println(“the sum of two value is :” +c);

    }
}

The Java Runtime Environment



The Java Runtime Environment (JRE) consists of the JVM and the program on the other. The Java Runtime Environment runs code compiled for the JVM by:


Loading the .class files
Verifying byte code
Executing the code

Twitter Delicious Facebook Digg Stumbleupon Favorites More