54
Java program to print the following pattern
*000*000*
0*00*00*0
00*0*0*00
000***000
Algorithm:
- STEP 1: START
- STEP 2: SET lines=4
- STEP 3: Define i, j
- STEP 4: SET i =1
- STEP 5: REPEAT STEP 6 to 15 UNTIL i <= lines
- STEP 6: SET j=1
- STEP 7: REPET STEP 8 and 9 UNTIL j <= lines
- STEP 8: IF i is equal to j PRINT * ELSE PRINT 0
- STEP 9: SET j = j + 1
- STEP 10: DECREMENT j by 1 and PRINT *
- STEP 11: REPEAT STEP 12 and 13 UNTIL j >=1
- STEP 12: IF i is equals to j PRINT * ELSE PRINT 0
- STEP 13: SET j = j – 1
- STEP 14: PRINT a new line
- STEP 15: SET i = i + 1
- STEP 16: END
Program:
Output:
*000*000* 0*00*00*0 00*0*0*00 000***000
Next TopicJava Programs