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.

Results 1 to 3 of 3

Thread: Need help with programming exercise.

  1. #1
    Junior Member
    Join Date
    Nov 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Need help with programming exercise.

    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.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,140
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Need help with programming exercise.

    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?

  3. #3
    Member
    Join Date
    Dec 2011
    Location
    United States
    Posts
    94
    My Mood
    Amused
    Thanks
    5
    Thanked 8 Times in 8 Posts

    Default Re: Need help with programming exercise.

    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.

Similar Threads

  1. Exercise
    By phite2009 in forum Member Introductions
    Replies: 3
    Last Post: September 30th, 2011, 08:51 AM
  2. Is this what my exercise want?
    By Arkeshen in forum Java Theory & Questions
    Replies: 3
    Last Post: May 16th, 2011, 04:51 PM
  3. [SOLVED] Exercise for study course help?
    By SweetyStacey in forum Object Oriented Programming
    Replies: 12
    Last Post: April 25th, 2010, 02:01 PM
  4. JAVA exercise
    By gmilan in forum What's Wrong With My Code?
    Replies: 0
    Last Post: March 13th, 2010, 02:30 PM
  5. Exercise problems
    By Virgildonatifan in forum Java Theory & Questions
    Replies: 0
    Last Post: February 14th, 2010, 04:12 AM