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 04-16-2008, 10:33 AM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
How to Print out adiamond pattern I try this code but
How to Print out adiamond pattern I try this code but it print out one Line
Code:
import java.util.*; public class Main { static Scanner console = new Scanner(System.in); public static void main(String[] args) { int numberofbalanks; int counter; int count; numberofbalanks =30; for(counter=1;counter<=6;counter++) { for(count=1;count<=blanks;count++) System.out.print(""); for(count=1;count<=starsinline;count++) System.out.print("*"); System.out.println(); } for(counter=5;counter>=0;counter--) { for(count=1;count<=blanks;count++) System.out.print(""); for(count=1;count<=starsinline;count++) System.out.print("*"); System.out.println(); } }
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 04-16-2008, 10:48 AM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
You should given a full code or compilable code here to test. I don't have an idea about few variables you used, like blanks and so on.

And also here in the following code, why did you do this.

Code:
int numberofbalanks; numberofbalanks =30;
Actually pal no need to use two lines for this.

Code:
int numberofbalanks = 30;
__________________
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 04-16-2008, 10:57 AM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
sanjeevtarar is on a distinguished road

Please post ....output that you want.


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 04-16-2008, 11:46 AM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
the image with attachment
Attached Images
File Type: jpg untitled.JPG (3.2 KB, 11 views)

Last edited by masaka : 04-16-2008 at 12:03 PM.
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 04-16-2008, 12:04 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
sanjeevtarar is on a distinguished road
Hello,


Try This..for output you given last time

*
**
***
****
*****
****
***
**
*


Code:
public class PrintStar { public static void main(String[] args){ printStars(); } public static void printStars(){ int k = 5; for (int i=0;i<9 ;i++ ){ if(i<5){ for (int j=0;j<=i;j++ ){ System.out.print("*"); } }else{ for (int j=0;j<=k-2;j++ ){ System.out.print("*"); } k--; } System.out.println(); } } }

sanjeev
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 04-16-2008, 12:08 PM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
Please check The image
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 04-16-2008, 12:31 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Why, what's wrong with sanjeev 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
  #8 (permalink)  
Old 04-16-2008, 12:33 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Ah, you have change the image. So try it with Sanjeev code. Actually you have to deal with some spaces there.
__________________
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 04-16-2008, 12:45 PM
sanjeevtarar's Avatar
Senior Member
 
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
sanjeevtarar is on a distinguished road

Ya, you have changed the image.
anyway i thing you can change in my code as per your requirements.


sanjeev
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 04-16-2008, 01:00 PM
sukatoa's Avatar
Senior Member
 
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
sukatoa is on a distinguished road
Send a message via Yahoo to sukatoa
THis could be done by having first an experiment on it....
write it, predict, code it, and realize....

Not on a hurry,
sukatoa
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 04-16-2008, 01:15 PM
Eranga's Avatar
Moderator
 
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
Eranga has a spectacular aura aboutEranga has a spectacular aura about
Send a message via Yahoo to Eranga
Yep, what you need to start work is there in the Sanjeev 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
  #12 (permalink)  
Old 04-16-2008, 03:52 PM
Member
 
Join Date: Mar 2008
Posts: 31
masaka is on a distinguished road
Thanks To all of you
Thanks alot for your help
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
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
Using Pattern.CASE_INSENSITIVE Java Tip Java Tips 0 01-10-2008 12:45 PM
Regex pattern ravian New To Java 4 12-11-2007 12:20 PM
Generating Code Automatically Using Custom code Template In Eclipse JavaForums Eclipse 1 04-26-2007 05:52 PM


All times are GMT +3. The time now is 02:58 AM.


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