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

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From Eric Sosman <esosman@comcast-dot-net.invalid>
Newsgroups comp.lang.java.programmer
Subject Re: Creating a diamond shape wtih java
Date Wed, 04 Sep 2013 20:33:52 -0400
Organization A noiseless patient Spider
Lines 56
Message-ID <l08jhl$qh$1@dont-email.me> (permalink)
References <ccc6b9c6-617f-4a17-b14c-9dab366d9025@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding 7bit
Injection-Date Thu, 5 Sep 2013 00:33:57 +0000 (UTC)
Injection-Info mx05.eternal-september.org; posting-host="0d73d8cc209bff1c6395088b400d0605"; logging-data="849"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/TR7i3Z1NFlN2S8q2W/S6l"
User-Agent Mozilla/5.0 (Windows NT 5.1; rv:17.0) Gecko/20130801 Thunderbird/17.0.8
In-Reply-To <ccc6b9c6-617f-4a17-b14c-9dab366d9025@googlegroups.com>
Cancel-Lock sha1:oixklguj/E8b5cMFsLvYMmOgB8U=
Xref csiph.com comp.lang.java.programmer:25224

Show key headers only | 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