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 4 of 4

Thread: How should I start this problem?

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How should I start this problem?

    Write a program that accepts an integer "n" and prints the following picture of a diamond with 2n-1 rows

    Number #3:

    photo (1).JPG


    I really need help with this i have no idea where to start.


  2. #2
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How should I start this problem?

    Don't worry about the whole problem, just work on smaller parts and build upon. Can you write code to produce:
      X
     XXX
    XXXXX
    If so then you are half way there. All you need to do after that is to repeat the pattern but upside down. Depending upon how you wrote the program you might end up with 2 middle lines. If so then work out how to eliminate one.
    Improving the world one idiot at a time!

  3. #3
    Junior Member
    Join Date
    Oct 2013
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How should I start this problem?

    Quote Originally Posted by Junky View Post
    Don't worry about the whole problem, just work on smaller parts and build upon. Can you write code to produce:
      X
     XXX
    XXXXX
    If so then you are half way there. All you need to do after that is to repeat the pattern but upside down. Depending upon how you wrote the program you might end up with 2 middle lines. If so then work out how to eliminate one.
    This is the only part I don't know how to do could you please explain some of it please.

  4. #4
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: How should I start this problem?

    Start with a piece of paper (graph paper would work well). Write down the all the X's for 3 or 4 lines. Then count how many X's and how many spaces are on each line. Do you see a pattern?
    Improving the world one idiot at a time!

Similar Threads

  1. Replies: 0
    Last Post: February 19th, 2013, 01:15 PM
  2. [SOLVED] Extremely Simple Problem... Im new. (illegal start of expression)
    By Zea in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 4th, 2013, 03:40 PM
  3. PROBLEM: ILLEGAL START OF EXPRESSION
    By zerfgog in forum What's Wrong With My Code?
    Replies: 1
    Last Post: April 29th, 2012, 06:24 AM