Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-06-2008, 03:49 PM
Member
 
Join Date: Oct 2008
Posts: 4
GeeKunMow is on a distinguished road
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
Sponsored Links
  #2 (permalink)  
Old 10-06-2008, 03:54 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,566
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 10-06-2008, 03:58 PM
Member
 
Join Date: Oct 2008
Posts: 4
GeeKunMow is on a distinguished road
Oh, wow. Thank you so much! I really appreciate it.
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 10-06-2008, 04:02 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,566
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 11-19-2008, 05:35 AM
Member
 
Join Date: Nov 2008
Posts: 12
jhen is on a distinguished road
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 05:37 AM.
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 11-19-2008, 05:38 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,566
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 11-19-2008, 10:17 AM
Member
 
Join Date: Nov 2008
Posts: 12
jhen is on a distinguished road
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, 10:20 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,566
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
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.

Has someone helped you? Then you can
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
their helpful post.

Want to make your IDE the best?
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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 11-19-2008, 10:36 AM
Member
 
Join Date: Nov 2008
Posts: 12
jhen is on a distinguished road
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
Sponsored Links
Reply


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

vB 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 02:50 PM
Behavioral Pattern - Iterator Pattern (Example) - 1 JavaForums Java Blogs 0 05-06-2008 02:50 PM
Strategy Pattern mew New To Java 0 01-25-2008 09:34 PM
Singleton Pattern Java Tip Java Tips 0 01-24-2008 05:21 PM
singleton pattern Peter Advanced Java 1 07-09-2007 06:45 AM


All times are GMT +3. The time now is 10:30 AM.


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