Posted by : Unknown
Sunday, 28 June 2015
import java.util.Scanner;
class pyramidShape
{
public static void main(String[] args)
{
System.out.print("Enter number of rows: ");
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*2-1;m++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
class pyramidShape
{
public static void main(String[] args)
{
System.out.print("Enter number of rows: ");
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*2-1;m++)
{
System.out.print("*");
}
System.out.print("\n");
}
}
}
Output:
Related Posts :
- Back to Home »
- for Loop , Simple Program »
- Display Star in pyramid format using java