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

1. ## printing the pattern

i want to know how to print this type of pattern when a name is given ???
example:

name given TEJA

Capture.PNG

2. ## Re: printing the pattern

Welcome to the Forum! Please read this topic to learn how to post code correctly and other useful tips for newcomers.

This is an interesting twist on ascii art that I haven't seen before. In general, it is accomplished with for loops, probably at least 2 loops - one nested in the other - but there may be helper loops in addition to those. You'll need to do some math up front. Determine how many lines there are (the outside loop), how many columns there are (the inside loop), and in this case you'll need to think about and calculate spacing for the spokes. When you've gotten that figured out just using pencil and paper for the example name you've given, then consider what might happen if the name input is a five-letter (or some odd number) name instead of an even number. How will that change the resulting pattern and the math involved?

After you have that roughed out, start coding. You might start by simply coding the pattern you've shown us using 4 asterisks as a constant name. Once you have that figured out, then move to substituting user input characters for the string of asterisks.

Good luck!

3. ## Re: printing the pattern

Start by taking a piece of graph paper and drawing the pattern on it.
Then look at what is printed on each line starting at the top.
The code will need to print a line for each line on the graph paper.
For each line that is to be printed, work out the spacing between each letter that is printed on that line.

4. ## Re: printing the pattern

+1 on starting with pencil and graph/squared paper. I would've done the same myself. If you don't have such paper at hand, you can go to Squared paper to download and print it yourself.

For good results, I'd also recommend using a monospaced font such as Courier, Courier New and Lucida Console on the display console (in your IDE or Windows command prompt) so that you get consistent spacing between letters.