🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: aus.computers.java
2 messages
2 total messages Started by Batesy Wed, 15 Mar 2000 00:00
Quick Help
#917
Author: Batesy
Date: Wed, 15 Mar 2000 00:00
32 lines
1285 bytes
Hi all,
Im nort sure if this is hte correct group to post to, but I have a small
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

Cheers
Jonathon Bates
Re: Quick Help
#923
Author: 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
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads