🔒 Closed Generate a pyramid

Status
Not open for further replies.

Bhadz141

Grasshopper
public class Pyramid
{
/* Generate a Pyramid using * symbols */
public static void main(String[] args)
{
int n = 8; // number of rows

int indent = 3;
for (int i = 1; i <= n; i++)
{
for (int j = 0; j < ((n + indent) - i); j++)
System.out.print(" ");
for (int k = 1; k <= i; k++)
System.out.print("*");
for (int k = 1; k < i; k++)
System.out.print("*");
System.out.println();
}

System.out.println();
}
}
 
Status
Not open for further replies.

About this Thread

  • 1
    Replies
  • 627
    Views
  • 2
    Participants
Last reply from:
Path_Finder

Trending Topics

Online now

Members online
1,337
Guests online
3,481
Total visitors
4,818

Forum statistics

Threads
2,305,879
Posts
29,168,309
Members
1,195,477
Latest member
Jomar Gabriel
Back
Top