The program below is the answer to Deitel’s Java How to Program (9th Edition) Chapter 2 Exercise 2.18. Write an application that displays a box, an oval, an arrow and a diamond using asterisks (*)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
/** * * Exercise 2.18 - Displaying Shapes With Asterisks * This Program Displays A Box, An Oval, An Arrow And A Diamond Using Asterisks (*) * */ public class Ex02_18 { public static void main (String [ ] args) { System.out.println (); System.out.print ("********* *** * * \n"); System.out.print ("* * * * *** * * \n"); System.out.print ("* * * * ***** * * \n"); System.out.print ("* * * * * * * \n"); System.out.print ("* * * * * * * \n"); System.out.print ("* * * * * * * \n"); System.out.print ("* * * * * * * \n"); System.out.print ("* * * * * * * \n"); System.out.print ("********* *** * * \n"); } } |
5 Comments
This is v inefficient. Uses loops for box and oval. The diamond and arrow are both combinations of two loops.
I think we can do it by System.out.println r u agree with me?
100 Errors, is there any liberary to add before execution?
None that I know of.
Is there any other way?