Link to home
Start Free TrialLog in
Avatar of warc_renegadex
warc_renegadexFlag for Australia

asked on

Design program to draw diamond depending on diameter size

Design, write in Java, test and document a program (application) that prints the following diamond shape. 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. The program should then display a diamond of the appropriate size. For example, if the number entered by the user is 9, the following diamond will be displayed:

        *
      ***
    *****
  *******
*********
  *******
    *****
      ***
        *

Note that the diamond is not to be printed by outputting strings as
System.out.println("      *     ");
System.out.println("    ***    ");
System.out.println("   *****   ");
System.out.println(" ******* ");
      System.out.println("*********");
      System.out.println(" ******* ");
System.out.println("  *****  ");
System.out.println("    ***    ");
System.out.println("      *     ");
Any solution that produces a diamond by outputting strings (as above) will fetch a zero mark.
Avatar of terajiv
terajiv

This Seems tobe Home work...isnt it?
ASKER CERTIFIED SOLUTION
Avatar of mrachow
mrachow

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of warc_renegadex

ASKER

so thanx to mrachow for your answer, this is a good idea. i had some other loops and while stuff in there but i couild not get to write a class as good as yours. now i'll write some main method and try it out.
hey mrachow
do you have a email address my is at w.ho@student.murdoch.edu.au or wmh97@hotmail.com