This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Soft Skills and have John Sonmez on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes display a pattern Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "display a pattern" Watch "display a pattern" New topic
Author

display a pattern

Alireza Bahmanpour
Greenhorn

Joined: Oct 24, 2007
Posts: 23
Hi, I had a simple question. I just needed to write a code to display the following pattern. I know it is easy, but the thing is, I am an absolute beginner (just started using java less than a week ago). So please don't laugh if its too easy. Here's the pattern:

The code I wrote is:

But this code displays the pattern wrongly, I don't know how I should change it to show the right thing

Thanks
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19063
    
  40

But this code displays the pattern wrongly, I don't know how I should change it to show the right thing


Well, it would help if you post in the right forum. This forum is for Java beginners -- and BTW, you program isn't Java.

Henry
[ October 24, 2007: Message edited by: Henry Wong ]

Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

This is not Java code -- I'm not quite sure what it is, honestly!


[Jess in Action][AskingGoodQuestions]
Alireza Bahmanpour
Greenhorn

Joined: Oct 24, 2007
Posts: 23
The code is a Groovy code (a new programming language, probably haven't heard of it, we just started doing this for the first time in uni). It's very similar to Java, in fact it's all based on java, with some added facilities. But even if you give me a psuedocode it would help.
Henry Wong
author
Sheriff

Joined: Sep 28, 2004
Posts: 19063
    
  40

Groovy is a scripting language -- and it goes into the object orient scripting forum.... not here. Anyway....


I won't give you the answer, as this is a homework problem. But here is a hint...

Keep in mind that there are spaces too (Just because you can't see them, doesn't mean that they don't exist). You need to modify the program to print both the "*" and the spaces on each line. If you just print the "*", you will be left justified.

Henry
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: display a pattern