Sunday, 26 May 2013

A Java program to show a pattern of stars on screen : Task


A JAVA program to show a patterns of stars on the screen.

First make a java project and then make class of name Star and then write down this whole code.

public class Star {


public static void main(String[] args) {
for(int i=1;i<=3;i++)
{
for(int j=3;j>i;j--)
{

System.out.print("");       //to print a blank space
}
for(int k=0;k<i*2-1;i++)
{
System.out.print("*");           // to print asterick*
}
System.out.println();                   // to goto next line
}

}

}

No comments:

Post a Comment