Results 1 to 6 of 6
  1. #1
    vxs
    vxs is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Smile Class pattern to generate following pattern:-

    How should I write a program so that it define a class pattern to generate following pattern inone program.

    I mean when I compile a program it executes all the patterns in one single program.

    I am new to JAVA...had been assigned this as a project work... but can't figure out how to do .PLZ help.

    A. A method takes an int. argument n and print the following
    a
    aaa
    aaaaa
    aaaaaaa
    aaaaa
    aaa
    a

    B. A method takes an int. arugument n and print following

    1
    121
    12321
    1234321
    12321
    121
    1

    C. A method takes an int. arugument n and print following

    1234321
    123 321
    12 21
    1 1



    D. A method takes an int. arugument n and print following


    55555
    54444
    54333
    54322
    54321

  2. #2
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,260
    Rep Power
    25

    Default

    It looks like you'll need a loop.
    What have you coded so far?

    Take it one step at a time.
    What is to print on the first line?
    What is to print on the second line? Is there a relationship between what line you are on and what is to print on that line?
    Continue until the last line.

  3. #3
    vxs
    vxs is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

    Default

    Thanks for the quick reply....
    I am still unable to get started on it..

  4. #4
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    26

    Default

    Quote Originally Posted by vxs View Post
    Thanks for the quick reply....
    I am still unable to get started on it..
    Hang in there. We'll be glad to help you out as long as you understand that we won't write this for you.

    Think of what logic you'd need if you were to do this on paper and then break this logic down into small steps, and then if you'd like post it here and we can go over this with you. An excellent resource to help you get started is the link in my signature titled "So you need to write a program but don't know how to start". Have a look at it as it can help you.

  5. #5
    Norm's Avatar
    Norm is online now Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,260
    Rep Power
    25

    Default

    Start with the HelloWorld program.
    Add a for loop around the println() with the "Hello World" message so that it prints out each time the loop goes around.

  6. #6
    vxs
    vxs is offline Member
    Join Date
    Jul 2010
    Posts
    3
    Rep Power
    0

Similar Threads

  1. Pattern
    By mtyoung in forum Advanced Java
    Replies: 9
    Last Post: 04-07-2009, 02:17 AM
  2. Logic to generate a pattern
    By vijay_2008 in forum Advanced Java
    Replies: 3
    Last Post: 11-23-2008, 02:40 AM
  3. Reading pattern using Scanner class
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 01-18-2008, 12:02 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •