Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2008, 01:49 PM
Member
 
Join Date: Oct 2008
Posts: 4
Rep Power: 0
GeeKunMow is on a distinguished road
Default Star pattern help?
I need some help making some star patterns. The exact instructions are as follows:

Create separate programs to produce the following patterns:
a.
*
**
***
****
*****

b.
*****
****
***
**
*


I have to use for loops to get the patterns and I've already got (a.) but I can't seem to get the second. My first pattern's code is this:

public class Stars
{
//-------------------------------------------
//Prints a triangle shape using asterick (star) characters.
//-----------------------------------------------------------
public static void main (String[] args)
{
final int MAX_ROWS = 10;

for (int row = 1; row <= MAX_ROWS; row++)
{
for (int star = 1; star <= row; star++)
System.out.print ("*");

System.out.println();
}
}
}
Please help? Thanks in advance!
Bookmark Post in Technorati
Reply With Quote
  #2 (permalink)  
Old 10-06-2008, 01:54 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,523
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
Simply do the process in other way around.

Code:
public class Stars {
//-------------------------------------------
//Prints a triangle shape using asterick (star) characters.
//-----------------------------------------------------------

    public static void main (String[] args) {

        final int MAX_ROWS = 10;
        for (int row = MAX_ROWS; row >= 0; row--) {
            for (int star = 1; star <= row; star++) {
                System.out.print ("*");
            }
            System.out.println();
        }
    }
}
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 01:58 PM
Member
 
Join Date: Oct 2008
Posts: 4
Rep Power: 0
GeeKunMow is on a distinguished road
Default
Oh, wow. Thank you so much! I really appreciate it.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-06-2008, 02:02 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,523
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
You are welcome!
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-19-2008, 03:35 AM
Member
 
Join Date: Nov 2008
Posts: 12
Rep Power: 0
jhen is on a distinguished road
Smile star
can i hav the explanation for the code u hv sent a while ago about creating a star?? coz i am little bit confuse?

Last edited by jhen; 11-19-2008 at 03:37 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-19-2008, 03:38 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,523
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
On what you are confusing, not what line of code?
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-19-2008, 08:17 AM
Member
 
Join Date: Nov 2008
Posts: 12
Rep Power: 0
jhen is on a distinguished road
Default star
wt is the used of final in the source code of creating a star??? y is it the identifier named row and star doesn't hav error eventhough it was not declared???
plz i nid uir help... tnx
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 11-19-2008, 08:20 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 6,523
Rep Power: 9
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Default
In Java final means constant. Basically the value cannot change at run time. Always it remain as the same. Just remove the word final and run the code. Still you get the same result. It's just for safety, in this case it's not much important but it's good practice.

Carefully check the code, both start and row identifiers are declared in the code.
__________________
Use an appropriate Subject. "Help, urgent!" isn't one.
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

Someone helped you?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.
Help:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Resources:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Web:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Tips:
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
|
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-19-2008, 08:36 AM
Member
 
Join Date: Nov 2008
Posts: 12
Rep Power: 0
jhen is on a distinguished road
Default TY
tnx.... it's a help for me to be one of the member of this forum....sayoonara....
Bookmark Post in Technorati
Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Behavioral Pattern - Iterator Pattern (Example) - 2 JavaForums Java Blogs 0 05-06-2008 12:50 PM
Behavioral Pattern - Iterator Pattern (Example) - 1 JavaForums Java Blogs 0 05-06-2008 12:50 PM
Strategy Pattern mew New To Java 0 01-25-2008 07:34 PM
Singleton Pattern Java Tip Java Tips 0 01-24-2008 03:21 PM
singleton pattern Peter Advanced Java 1 07-09-2007 04:45 AM


All times are GMT +2. The time now is 05:35 PM.



VBulletin, Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2009, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org