• Post Reply Bookmark Topic Watch Topic
  • New Topic

Help for pyramid  RSS feed

 
Jeffrey Setiawan
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
let's said i put 3 value in beginning and 3 value for size of pyramid ( 1st value for how many pyramid and 2nd is the size of pyramid) with asterix
the result will like this
xxxx*
xxx **
xxxx***
xxxx *
xxx**
xxx***
xxxx*
xxxx**
xxx***
PS: x is space
please help me
me still really learning Thanks for helping
 
Sudipta Laha
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If i write the code for this. It will be no help for you.

you can write the code itself. Will like to give you a suggestion. may be it will help.

1. Write a program which will print a pyramid of your height. Use only System.out.println() and write the whole structure manually.
2. Then try to figure out from that program how can you make all the print statement in a loop. Try to identify the logical relation between the different print statement.
3. Once you do that you will be able code the for loop appropriately.
4. modify your code for more number for pyramids using another for loop.

Its all about identifying the pattern. I believe this will help.

 
Campbell Ritchie
Marshal
Posts: 56570
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That was a helpful reply Sudipta Laha.

Welcome to the Ranch

Don't try to do the whole thing at once. Write three lines, compile and run it, then add one line at a time. run it after each change, and see how it develops. It is much easier like that.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!