warc_renegadex
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.
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.
This Seems tobe Home work...isnt it?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
ASKER
hey mrachow
do you have a email address my is at w.ho@student.murdoch.edu.a u or wmh97@hotmail.com
do you have a email address my is at w.ho@student.murdoch.edu.a