What's new

Closed Generate a pyramid

Status
Not open for further replies.

Bhadz141

Addict
Joined
Jun 1, 2016
Posts
30
Reaction
15
Points
81
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.

Similar threads

Back
Top