File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Beginning Java and the fly likes This is Homework Just need a hint:????? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "This is Homework Just need a hint:?????" Watch "This is Homework Just need a hint:?????" New topic
Author

This is Homework Just need a hint:?????

Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
I am using for loops to get a pattern printed I have one for loop for my rows and then seven for loops to print 4 triangles and three blank spaces. I can print all my triangles and my space but I am having trouble getting my 3 tri mirror my 2nd and my 4 tri mirror my frirst. I am printing out of "*". Yes this is an assignment. I don't want the code maybe just a good hint;
Thank you Ryan Perlman
Bend,Or

*_____*****_*****_____*
**____****___****____**
***___***_____***___***
****__**_______**__****
*****_*_________*_*****
Paul Stevens
Ranch Hand

Joined: May 17, 2001
Posts: 2823
You could always replace your 7 loops with a method to print a char x number of times.
Junilu Lacar
Bartender

Joined: Feb 26, 2001
Posts: 4419
    
    5

Start by doing everything by hand, then look for a pattern. When you find a pattern, figure out a way of automating the progression in a loop.
Your pattern goes something like this:
* (x1) _ (x5) * (x5) _ (x1) * (x5) _ (x5) * (x1)
* (x2) _ (x4) * (x4) _ (x2) * (x4) _ (x4) * (x2)
* (x3) _ (x3) * (x3) _ (x3) * (x3) _ (x3) * (x3)
* (x4) _ (x2) * (x2) _ (x4) * (x2) _ (x2) * (x4)
* (x5) _ (x1) * (x1) _ (x5) * (x1) _ (x1) * (x5)
Now that you can see the progression a little better, figure out what kind of calculations you need in your loop.

Junilu - [How to Ask Questions] [How to Answer Questions]
Ryan Perlman
Greenhorn

Joined: Oct 31, 2001
Posts: 23
Thanks to all the reason I didn't write a method is because technically I don't know how yet it is the next chapter in the book. I was spose to write this using the for loop and
System.out.print(' ');
Here was my actual question
modify exercise 5.10 into a single application that prints all four patterns side by side making clever use of nested for loops
5.10
write an app that displays the following patterns separately one below the other. use for loops to generate the patterns. They should be printed by a single statement of the form System.out.print('*'); and System.out.print(' '); the last two patterns require that each line begin with an appropriate number of blank spaces. (That is what was killing me); I did get it and I won't post it. since I have noticed This same and similar question here before.

Perservere and you shall succeed!!!
Ryan Perlman
Bend, Oregon
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: This is Homework Just need a hint:?????
 
Similar Threads
all confused about scope....
How does a true mirror work?
Nested Loops
Problem with spacing
Paradoxes and Ironies!!!!