Java program for printing star pattern vertically

import java.io.*;
import java.util.*;
public class sansvertical
{
public static void main(String args[])
{

int limit,i,j;
Scanner s=new Scanner(System.in);
System.out.print("enter the number of starts in the first line\t:");
limit=s.nextInt();
System.out.println();
for(i=limit;i>=1;i--)
{
for(int space=0;space<=(limit-i);space++)
{
System.out.print("  ");
}
for(j=1;j<=i;j++)
{
System.out.print("* ");
}
System.out.println();
}
for(i=2;i<=limit;i++)
{
for(int space=0;space<=(limit-i);space++)
{
System.out.print("  ");
}
for(j=1;j<=i;j++)
{
System.out.print("* ");
}
System.out.println();
}


}
}

OUTPUT

ask your questions as comments here!!!
Share on Google Plus
    Blogger Comment
    Facebook Comment

3 comments:

  1. *
    ** **
    *** ***
    ** **
    *


    How to Write this program to Print Star Pattern in Java

    ReplyDelete
    Replies
    1. Really Nice Post to Print Star Pattern in Java Yesterday I visit this blog and i was found lots of helpful information from your side thanks for sharing updated and New Technology related Post.

      Delete