Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Loops in a Pyramid problem

1. ## Loops in a Pyramid problem

Hello everyone,

Eventhough this is my first post, I've been reading, and browsing this forum a lot. I have a problem figuring out how to draw a pyramid as follow (minus the *s)

********A
******A*B*A
****A*B*B*B*A
**A*B*B*B*B*B*A
A*B*B*B*B*B*B*B*A
The problem is that it has A, B and a space between them.

I was thinking of drawing two separate pyramid, as follow:

********A
******A***A
****A*******A
**A***********A
A***************A
And another one:

********B
******B*B*B
****B*B*B*B*B
**B*B*B*B*B*B*B

However, I really appreciate all your input/help on this. I seem to have a hard time finding a good mathematic equation for the "for loops"

2. ## Re: Loops in a Pyramid problem

You aren't really going to be able to draw them separately.

I'd start out by drawing a pyramid with a single character, then taking care of the special cases after you have that working.

3. ## Re: Loops in a Pyramid problem

Originally Posted by KevinWorkman
You aren't really going to be able to draw them separately.

I'd start out by drawing a pyramid with a single character, then taking care of the special cases after you have that working.