Post deleted
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
Members have full access to the forums. Advertisements are removed for registered users.
Post deleted
Last edited by jericajam; August 26th, 2011 at 07:07 PM.
Most important advice you can get: don't shove all your code into the main method. Break it down into smaller chunks and put each of these into their own methods.
main method { while user has not finished { get user choice if user selects c { call method to print normal pyramid else if user selects d { call method to print upside down pyramid } // etc } }
I would set up the for loops as follows: Have one outside loop, with two other loops nested inside it, calculating spaces and size of the tree:
for ( ; ; ){ // Represents what row is being worked on for ( ; ; ){ // Represents the column for spaces // Print space(s) } // Make sure you decrement amount of spaces here for ( ; ; ) { // Represents the column for the asterisks // Print asterisk(s) } // Begin a new line }
Asking Questions for Dummies | The Java Tutorials | Java Coding Styling Guide"Everything should be made as simple as possible, but not simpler."
Hello jericajam.
Welcome to the forums.
Please use the forum search function or check the "Similar Threads" box at the bottom of this thread.
The 'pyramid for loop' question has been asked time and time again.
Please use [highlight=Java] code [/highlight] tags when posting your code.
Forum Tip: Add to peoples reputation by clicking the button on their useful posts.