Results 1 to 11 of 11
  1. #1
    SNFA is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default Program that displays JAVA word pattern.

    Hi,

    I am new here and thought I would see if anyone had any ideas on this program I am working on. I believe it is a loop. I need to set up the word JAVA with the letter J being made up of 6 Js, letter A 10 As, letter V 8 Vs, and last A 10 As.

    I letters looks something like this and go across:

    J
    J
    J J
    J J


    A
    AA
    AAAAA
    A A


    V V
    V V
    V V
    V

    So far I got the basic programming down:

    public class JavaPattern {
    public static void main (String[] args) {

    //Create Java Pattern

    Do I need to set up something to display the word: JAVA
    This is in the first chapter of my book under programming exercises, but there is nothing in the book pertaining to creating patterns.

    I am taking an online program, so I am not in contact with my instructor very often. Most of this I have been figuring out myself. Could someone explain how you create a pattern like this.

    Thanks
    Diana

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,882
    Rep Power
    8

    Default

    To preserve the formatting of your letter arrangements, try using the code tags.

    I would get out a piece of graph paper and draw out the pattern. Write down the steps you're following (even if you're just following them in your head without actually thinking about them). When you have the steps written down specifically enough that you could hand them to a stranger and have them do the same thing without knowing the end goal, then try translating those steps to code.

  3. #3
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    Please give us more explanation.

    Do you want something like this:
    J
    JJ
    JJJ
    JJJJ
    ...
    JJJJJJJ

    A
    AA
    AAA
    AAAA
    ...
    AAAAAAAAAA

    V
    VV
    VVV
    VVVV
    VVVVV
    ...
    VVVVVVVV

    A
    AA
    AAA
    AAAA
    AAAAA
    AAAAAA
    ...
    AAAAAAAAAA

    or maybe you want something like that:

    JJJJJJAAAAAAAAAAVVVVVVVVAAAAAAAAAA

  4. #4
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,882
    Rep Power
    8

    Default

    I am pretty sure he (edit- she) wants something like this:

    Java Code:
        J     A       V       V    A 
        J    A A       V    V    A A
    J   J   AAAA       V V    AAAA 
     J J   A      A       V    A      A
    Edit- Not quite, but you get the picture.
    Last edited by KevinWorkman; 10-08-2010 at 08:14 PM.

  5. #5
    SNFA is offline Member
    Join Date
    Oct 2010
    Posts
    4
    Rep Power
    0

    Default RE

    The pattern forms the letters J A V A.

    When I try to enter it here it shows up wrong. Think of the shape of a diamond made up of all "*" to create the pattern of the diamond.

    The letter J is created by 6 "J"s, letter A is created by "A"s, letter V by "V"s, and last "A" by As.

    The word itself goes across like this J A V A

    Too bad it doesn't show up right when I type it out.

    Thanks

    Diana

  6. #6
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,882
    Rep Power
    8

    Default

    Quote Originally Posted by SNFA View Post
    When I try to enter it here it shows up wrong.
    How does it show up? You should probably post some code that demonstrates the problem.


    Quote Originally Posted by SNFA View Post
    Too bad it doesn't show up right when I type it out.
    That's because the forum editor doesn't preserve spacing. If you use the code tags, you should have more luck.

    Did you try the graph paper idea? Notice any patterns?

  7. #7
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    I have written small piece of code.

    Java Code:
    public class BigLetters {
    	public static void main(String[] args) {
    		System.out.printf("    %s", "J");
    		System.out.println();
    		System.out.printf("    %s", "J");
    		System.out.println();
    		System.out.printf("%s   %s", "J","J");
    		System.out.println();
    		System.out.printf(" %s %s", "J", "J");
    		
    	}
    }
    It seems it can be done on a better way.

  8. #8
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    I know that spoonfeeding != helping. This is a website for writing code not for philosophers. Do not try to talk about philosophy like spoon... etc.

    Have you got any idea how it could be done?

    If they want loop then they might want to have 3 methods, one for any letter, and then to print "JAVA" with combination of that methods?

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default

    Here's an idea:
    Map out each letter as a number of rows of spaces and letters as needed.
    Have a method that will print the specified row for its letter w/o the line end(\n).
    Then a loop to call each method with the row number of the row it is to print out.

  10. #10
    cselic is offline Senior Member
    Join Date
    Apr 2010
    Location
    Belgrade, Serbia
    Posts
    278
    Rep Power
    5

    Default

    My another idea is:

    0001
    0001
    1010
    0110

    Make a combinations of 0 and 1. When there is 1 you should put a letter. You can write that function on many ways.

    Little difficult:
    It can also be done with four 16bit numbers for example
    0001000110100110 number for letter J :cool:

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

    Default

    I'm closing this thread as it's getting way off topic. Original poster, if you are still stuck, I'm sorry to do this, but I'm going to ask you to start a new thread and add a link to this one. Sorry for any inconvenience.

    Pete

Similar Threads

  1. Longest word in a program...
    By hustlas4ever in forum New To Java
    Replies: 5
    Last Post: 08-20-2010, 01:34 PM
  2. Class pattern to generate following pattern:-
    By vxs in forum New To Java
    Replies: 5
    Last Post: 07-14-2010, 11:15 PM
  3. Replies: 0
    Last Post: 03-28-2008, 08:46 PM
  4. Problem when displays in the terminal
    By Felissa in forum Advanced Java
    Replies: 2
    Last Post: 07-01-2007, 02:14 AM

Posting Permissions

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