/* Lab : Lab3 Day : Tuesday [ 12 Aug 08 ] Problem Number: 03 Problem Title : Print arrow head of goven size Theory : Consider following facts 1. The statement System.out.println(); will move the cursor to a new line 2. The statement System.out.println("*"); will print a * on current cursor position 3. If we execute Stetement System.out.println("*"); x times Then x number of * will appear on current curser position Let's combile fact 1 and 2 , to print x times * on a new line, following statement is to be written { System.out.println(); for( i = 1 ; i <= x ; i = i + 1) System.out.print("*"); } 4. Now our program is easy To print arrow head of size s 4a. To print upper head --- * ^ ** | *** s **** | ***** | ****** --- ******* call above body (fact 3) with value ox x in increasing order satrting fron 1 upto s 4b. to print bottom part --- ****** ^ ***** | **** s-1 *** | ** --- * call above body (fact 3) with value ox x in decreasing order order satrting fron s-1 to 1 */ class sol_lab3_prob03{ public static void main(String args[]) { // declare an integer variable s for the size of arrow head int s; s = 10; // assign size of arrow head to s int i; // counter variable for outer loop int j; // counter variable for inner loop // display upper part of arrow for( i = 1 ; i <= s ; i = i + 1 ) { System.out.println(); for( j = 1 ; j <= i ; j = j + 1 ) { System.out.print("*"); } } // display lower part of arrow for( i = s-1 ; i >= 1 ; i = i - 1 ) { System.out.println(); for( j = 1 ; j <= i ; j = j + 1 ) { System.out.print("*"); } } System.out.println(); } }