Results 1 to 2 of 2
  1. #1
    romina is offline Member
    Join Date
    Jul 2007
    Posts
    26
    Rep Power
    0

    Default Will make a pyramid of some kind out of a number

    Hi, I need to do a program where the user needs to imput a number of lines between 1 and 8 and then the program will make a pyramid of some kind out of a number that is 2^x (1-2-4-8-16 etc). I can calculate and have the numbers but I have no freaking idea how to put them like in the following exemple in the image.

    ex :

    Number of lines = 4. There's supposed to be 4 space between each column.

    Java Code:
                            1
                   1        2       1
            1      2        4       2      1
    1       2      4        8       4      2       1
    I have to do it with "for" loops. Anyone have any idea?
    Thanks.

  2. #2
    trill is offline Member
    Join Date
    Jul 2007
    Posts
    40
    Rep Power
    0

    Default

    Do you have any code written, that you can show? I'd rather fix your code, than give you mine.

    Mess around with a for loop printing the numbers out and you should be able to massage the code to fit your application fairly easily. You might want to declare a variable that acts like a spacer that's a String of 4 spaces to help with your formatting.

    Greetings.

Similar Threads

  1. how client know what kind of server
    By lemur in forum Networking
    Replies: 3
    Last Post: 05-31-2008, 08:11 AM
  2. i need help to make this program
    By masaka in forum New To Java
    Replies: 2
    Last Post: 03-23-2008, 02:26 PM
  3. How to make popups like in eclipse
    By ekadosh in forum SWT / JFace
    Replies: 0
    Last Post: 02-04-2008, 08:58 AM
  4. can i make a login form?
    By mitsakos in forum New To Java
    Replies: 2
    Last Post: 12-19-2007, 11:14 PM
  5. make a variable name from a string?
    By Kinnikinnick in forum New To Java
    Replies: 3
    Last Post: 11-13-2007, 04:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •