Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #25223
| Newsgroups | comp.lang.java.programmer |
|---|---|
| Date | 2013-09-04 17:15 -0700 |
| Message-ID | <ccc6b9c6-617f-4a17-b14c-9dab366d9025@googlegroups.com> (permalink) |
| Subject | Creating a diamond shape wtih java |
| From | johnnyringo888@gmail.com |
I have to create a diamond shape for my java class.
*
***
*****
*******
*********
*******
*****
***
*
Here is the code I have written so far. Can any provide assistance?
public class Diamond
{
public static void main (String[] args)
{
for ( int i = 1; i <= 10; i++ )
{
for ( int j = 0; j < i; j++ )
{
System.out.print ("*");
}
{
System.out.println ("\n");
}
}
for ( int i = 10; i > 0; i-- )
{
for ( int j = 0; j < i; j++ )
{
System.out.print ("*");
}
{
System.out.println ("\n");
}
}
for ( int i = 10; i > 0; i-- )
{
for ( int j = 0; j < (10 - i); j++ )
{
System.out.print (" ");
} }
for ( int j = 0; j < i; j++ )
{
System.out.print ("*");
}
{
System.out.println ("\n");
}
}
for ( int i = 1; i <= 10; i++ )
{
for ( int j = 0; j < (10 - i); j++ );
{
System.out.print (" ");
}
for ( int j = 0; j < i; j++ );
{
System.out.print ("*");
}
{
System.out.println ("\n");
}
}
}
}
When I compile this is what I get:
*
**
***
****
*****
******
*******
********
*********
**********
**********
*********
********
*******
******
*****
****
***
**
*
**********
*********
********
*******
******
*****
****
***
**
*
*
**
***
****
*****
******
*******
********
*********
**********
Back to comp.lang.java.programmer | Previous | Next — Next in thread | Find similar | Unroll thread
Creating a diamond shape wtih java johnnyringo888@gmail.com - 2013-09-04 17:15 -0700
Re: Creating a diamond shape wtih java Eric Sosman <esosman@comcast-dot-net.invalid> - 2013-09-04 20:33 -0400
Re: Creating a diamond shape wtih java Roedy Green <see_website@mindprod.com.invalid> - 2013-09-07 14:10 -0700
Re: Creating a diamond shape wtih java John Stephens <johnnyringo888@gmail.com> - 2013-09-04 17:46 -0700
Re: Creating a diamond shape wtih java Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-09-05 00:20 -0300
Re: Creating a diamond shape wtih java Jeff Higgins <jeff@invalid.invalid> - 2013-09-05 03:32 -0400
Re: Creating a diamond shape wtih java Arved Sandstrom <asandstrom2@eastlink.ca> - 2013-09-05 09:44 -0300
Re: Creating a diamond shape wtih java John Stephens <johnnyringo888@gmail.com> - 2013-09-08 09:00 -0700
csiph-web