Hi, my name is Courtney and I'm a bit new to Java. I'm trying to do a few exercises but I'm getting stuck.
Here is the first one.
Write for loops to produce the following output:
*
**
***
****
*****
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.
Hi, my name is Courtney and I'm a bit new to Java. I'm trying to do a few exercises but I'm getting stuck.
Here is the first one.
Write for loops to produce the following output:
*
**
***
****
*****
Last edited by X0BeachBabe0x; November 24th, 2011 at 01:54 PM.
You'll need two loops, the outer for the number of lines you want to print.
The inner one for printing the number of *s on that line.
Do you see the relationship between the line number and the number of *s on that line?
There is another cheap way of doing so. Use five print statements each one with different number of *s. I am not trying to do this for you but consider the fact that you have 1 * in the first row, 2, 3, 4, 5 consecutively. You also have 5 columns. Play around the two for-loops and you will be better at it.