Results 1 to 11 of 11
- 10-08-2010, 07:23 PM #1
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
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
- 10-08-2010, 07:49 PM #2
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.
- 10-08-2010, 07:55 PM #3
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
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
- 10-08-2010, 08:06 PM #4
I am pretty sure he (edit- she) wants something like this:
Edit- Not quite, but you get the picture.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 ALast edited by KevinWorkman; 10-08-2010 at 08:14 PM.
- 10-08-2010, 08:09 PM #5
Member
- Join Date
- Oct 2010
- Posts
- 4
- Rep Power
- 0
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
- 10-08-2010, 08:16 PM #6
How does it show up? You should probably post some code that demonstrates the problem.
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?
- 10-08-2010, 08:50 PM #7
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
I have written small piece of code.
It seems it can be done on a better way.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"); } }
- 10-08-2010, 09:13 PM #8
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
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?
- 10-08-2010, 09:27 PM #9
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-08-2010, 09:47 PM #10
Senior Member
- Join Date
- Apr 2010
- Location
- Belgrade, Serbia
- Posts
- 278
- Rep Power
- 4
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:
-
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
-
Longest word in a program...
By hustlas4ever in forum New To JavaReplies: 5Last Post: 08-20-2010, 01:34 PM -
Class pattern to generate following pattern:-
By vxs in forum New To JavaReplies: 5Last Post: 07-14-2010, 11:15 PM -
Addition program that displays the sum of two numbers
By Java Tip in forum Java TipReplies: 0Last Post: 03-28-2008, 08:46 PM -
Problem when displays in the terminal
By Felissa in forum Advanced JavaReplies: 2Last Post: 07-01-2007, 02:14 AM


LinkBack URL
About LinkBacks


Bookmarks