Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.programmer > #25224

Re: Creating a diamond shape wtih java

From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Creating a diamond shape wtih java
Date 2013-09-04 20:33 -0400
Organization A noiseless patient Spider
Message-ID <l08jhl$qh$1@dont-email.me> (permalink)
References <ccc6b9c6-617f-4a17-b14c-9dab366d9025@googlegroups.com>

Show all headers | View raw


On 9/4/2013 8:15 PM, johnnyringo888@gmail.com wrote:
> I have to create a diamond shape for my java class.
>
>       *
>      ***
>     *****
>    *******
>   *********
>    *******
>     *****
>      ***
>       *
>
> Here is the code I have written so far. Can any provide assistance?

     Since it's homework (you're honest about that; good!) I
think a hint may be of more value than a solution.  Here's the
hint: Imagine that you were assigned to print

	oooo*oooo
	ooo***ooo
	oo*****oo
	o*******o
	*********
	o*******o
	oo*****oo
	ooo***ooo
	oooo*oooo

instead.  How would you go about it?  If you solve this modified
problem, then replacing each "o" with a " " solves the original.
For extra credit (we call it "optimization"), try

	oooo*
	ooo***
	oo*****
	o*******
	*********
	o*******
	oo*****
	ooo***
	oooo*

and see how you make out.

     One further hint:

	System.out.println ("\n");

prints the "\n" string, which usually ends the current line and
begins a new one.  Next, it ends the current line and begins a
new one.  How many new-and-begin operations is that?

-- 
Eric Sosman
esosman@comcast-dot-net.invalid

Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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