|
|
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.
|
|

04-16-2008, 10:33 AM
|
|
Member
|
|
Join Date: Mar 2008
Posts: 31
|
|
|
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
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();
}
}
|
|

04-16-2008, 10:48 AM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
|
|
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.
int numberofbalanks;
numberofbalanks =30;
Actually pal no need to use two lines for this.
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.
|
|

04-16-2008, 10:57 AM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
|
|
|
Please post ....output that you want.
sanjeev
|
|

04-16-2008, 11:46 AM
|
|
Member
|
|
Join Date: Mar 2008
Posts: 31
|
|
|
the image with attachment
Last edited by masaka : 04-16-2008 at 12:03 PM.
|
|

04-16-2008, 12:04 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
|
|
Hello,
Try This..for output you given last time
*
**
***
****
*****
****
***
**
*
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
|
|

04-16-2008, 12:08 PM
|
|
Member
|
|
Join Date: Mar 2008
Posts: 31
|
|
|
Please check The image
|
|

04-16-2008, 12:31 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
|
|
|
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.
|
|

04-16-2008, 12:33 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
|
|
|
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.
|
|

04-16-2008, 12:45 PM
|
 |
Senior Member
|
|
Join Date: Apr 2008
Location: Delhi(India)
Posts: 251
|
|
|
Ya, you have changed the image.
anyway i thing you can change in my code as per your requirements.
sanjeev
|
|

04-16-2008, 01:00 PM
|
 |
Senior Member
|
|
Join Date: Jan 2008
Location: Cebu City, Philippines
Posts: 527
|
|
|
THis could be done by having first an experiment on it....
write it, predict, code it, and realize....
Not on a hurry,
sukatoa
|
|

04-16-2008, 01:15 PM
|
 |
Moderator
|
|
Join Date: Jul 2007
Location: Colombo, Sri Lanka
Posts: 4,592
|
|
|
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.
|
|

04-16-2008, 03:52 PM
|
|
Member
|
|
Join Date: Mar 2008
Posts: 31
|
|
|
Thanks To all of you
Thanks alot for your help
|
|
| Thread Tools |
|
|
| Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
|
|