🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: aus.computers.java
Article #923

Re: Quick Help

#923
From: Paul Murray
Date: Fri, 17 Mar 2000 00:00
61 lines
2302 bytes
"Batesy" <batesy@metallica.com> wrote in message
news:38cf74f3$0$1930@motown.iinet.net.au...
> problem with a bit of code. My tutor wants us to do the following:
>
> You may use output statements that
> print a single asterisk (*), a single space or a single newline character.
> Maximise your use of repetition (with nested loops) and minimise the
> number
> of output statements.
>
> The program should ask the user to enter an odd number in the range 1 to
> 21
> to specify the number of rows in the diamond.
>         *
>        ***
>       *****
>      *******
>     *********
>      *******
>       *****
>        ***
>         *
> Now this really has me stumped. Can someone please explain it to
> me please?
> If you would like to email any suggestions emailme at:
> batesy@batesy.iinet.net.au

Yeah, I'm glad this guy is not giving me specs to code to.

Write a java program to print a diamond. It should promt the user for an odd
number as input, and print a diamond with the specified number of rows. The
diamond will be made up of spaces, asterisks and end-lines.

Your tutor wants to see you use loops and whatnot to do the job. Recursive
functions are right out (sorry).

so you will wind up with something like

class foo {
    main() {
        get odd number from user;

        print a diamond to System.out;
    }
}

C:> java foo
Please enter an odd number: 4
4 is not an odd number.
Please enter an odd number: 5
  *
 ***
*****
 ***
  *

Go to it, code boy!

--------------------------------------------------------------
http://www.users.bigpond.com/pmurray
ICQ: 26066755
Technical Details
Message-ID: <f9WA4.35363$oD3.6830@newsfeeds.bigpond.com>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <38cf74f3$0$1930@motown.iinet.net.au>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10d6db,828334780a285ee
X-Google-Attributes: gid10d6db,public
From: "Paul Murray" <pmurray@nospam.bigpond.com>
Subject: Re: Quick Help
Date: 2000/03/17
Message-ID: <f9WA4.35363$oD3.6830@newsfeeds.bigpond.com>
X-Deja-AN: 599375379
References: <38cf74f3$0$1930@motown.iinet.net.au>
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6600
X-Trace: newsfeeds.bigpond.com 953429707 139.134.123.70 (Sun, 19 Mar 2000 12:35:07 EST)
Organization: Telstra BigPond Internet Services (http://www.bigpond.com)
NNTP-Posting-Date: Sun, 19 Mar 2000 12:35:07 EST
Newsgroups: aus.computers.java