Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 07-16-2007, 11:33 PM
Member
 
Join Date: Jul 2007
Posts: 26
romina is on a distinguished road
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.

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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 08-07-2007, 06:20 AM
Member
 
Join Date: Jul 2007
Posts: 40
trill is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +3. The time now is 12:21 AM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org