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

Thread: How do I program the following Java pattern?

  1. #1
    Junior Member
    Join Date
    Jun 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default How do I program the following Java pattern?

    1
    $ #
    1 $ 1
    # 1 1 1
    $ 1 # 1 $

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How do I program the following Java pattern?

    Before writing any code, create the algorithm that will print that design. I assume that you want to print.
    Once you have that, then try writing the code.

    If you have problems writing the code for the algorithm, post the algorithm and ask questions about the problems you are having with writing code for it.
    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Junior Member
    Join Date
    Jun 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do I program the following Java pattern?

    Quote Originally Posted by Norm View Post
    Before writing any code, create the algorithm that will print that design. I assume that you want to print.
    Once you have that, then try writing the code.

    If you have problems writing the code for the algorithm, post the algorithm and ask questions about the problems you are having with writing code for it.
    Hi, I have a problem with the algorithm. I know how to print the pattern but I don't know the algorithm.
    Thanks.

  4. #4
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How do I program the following Java pattern?

    I don't know the algorithm
    Ok, Do you see any pattern in what is printed line by line?

    I don't see any pattern. I'll leave it to you to find the algorithm.
    This is not a java programming problem until you have the algorithm and are ready to write the java code for it.
    If you don't understand my answer, don't ignore it, ask a question.

  5. #5
    Junior Member
    Join Date
    Jun 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do I program the following Java pattern?

    If you print a triangular pattern from 1 -15, all the dollars and hashes are prime numbers excpet the last one which is 15. So the pattern : 2,3,5,7,11,13,15, with alternating hashes and dollars. The 15 is the only one preventing it from becoming a full on pattern.

    P.S : I don't know whether I have posted this in the right place, under "What's wrong with my code?". I am new to this.
    Thanks
    Last edited by isitcat; June 8th, 2020 at 08:10 AM.

  6. #6
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How do I program the following Java pattern?

    Ok. Now can you define what is to be printed on each line?
    If you don't understand my answer, don't ignore it, ask a question.

  7. #7
    Junior Member
    Join Date
    Jun 2020
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: How do I program the following Java pattern?

    Sorry,I didn't understand what you mean to say by define.

  8. #8
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: How do I program the following Java pattern?

    I meant for you to post a detailed description of what prints on each line and why that value should be printed.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Pattern
    By DoctorBoris in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 29th, 2018, 10:15 AM
  2. pattern program
    By AJAY KAMBLE in forum What's Wrong With My Code?
    Replies: 8
    Last Post: February 16th, 2014, 08:32 AM
  3. Pattern printing in Java
    By arunjib in forum Loops & Control Statements
    Replies: 4
    Last Post: July 1st, 2011, 04:05 PM
  4. Regular Expression pattern - complex pattern syntax
    By SmartAndy in forum Algorithms & Recursion
    Replies: 3
    Last Post: June 7th, 2011, 04:40 AM
  5. Urgent need a java regex pattern
    By mallikarjun_sg in forum Java Theory & Questions
    Replies: 1
    Last Post: May 6th, 2010, 05:51 AM