Advertisements
Offline
Meisterk1risaki
Posts: 1
Joined: Thu Jan 17, 2013 9:52 pm
Enter the side of the rhombus:
Code: Select all
*
    *   *
   *  *  *
     *  *
       *

help me cause im newbie in here...tnx...
Offline
ajitpaswan
Posts: 11
Joined: Mon Dec 24, 2012 2:41 am
Location: India
Here is the program :

import java.util.Scanner;


public class PatternGenerator {
public static void main (String[] args) {
System.out.print("Enter no of row u want in star pattern : ");
Scanner in = new Scanner(System.in);
int num=in.nextInt();
for(int i=1;i<=num;i++)
{
for(int j=num;j>=i;j--)
{
System.out.print(" ");
}
for(int m=1;m<=i;m++)
{
System.out.print(" *");
}
System.out.print("\n");
}
for(int i=1;i<=num;i++)
{
for(int j=1;j<=i;j++)
{
System.out.print(" ");
}
for(int m=num;m>=i;m--)
{
System.out.print(" *");
}
System.out.print("\n");
}

}
}


The output :
Enter no of row u want in star pattern : 5
*
* *
* * *
* * * *
* * * * *
* * * * *
* * * *
* * *
* *
*