Latest Tutorials| Questions and Answers|Ask Questions?|Site Map



Home Answers Viewqa Java-Beginners print this image in java code using only loop{for, if, loop}

Have Programming Question? Ask it here!
 
 
 


vijay jaiswal
print this image in java code using only loop{for, if, loop}
1 Answer(s)      a year and 9 months ago
Posted in : Java Beginners


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

Advertisement
View Answers

October 20, 2012 at 5:20 PM


Here is a code that displays the following pattern:

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



class SwastikPattern{
    public static void main(String[] args){

 char s[][]=new char[10][10];
 int i,j;

 for(i=0;i<9;i++)
 {
   for(j=0;j<9;j++)
   {
   s[i][j]='*';
   }
 }
 for(i=0;i<4;i++)
 {
   for(j=1;j<4;j++)
   {
   s[i][j]=' ';
   }
 }
 for(i=1;i<4;i++)
 {
   for(j=5;j<9;j++)
   {
   s[i][j]=' ';
   }
 }
 for(i=5;i<8;i++)
 {
   for(j=0;j<4;j++)
   {
   s[i][j]=' ';
   }
 }
 for(i=5;i<9;i++)
 {
   for(j=5;j<8;j++)
   {
   s[i][j]=' ';
   }
 }
 for(i=0;i<9;i++)
 {
   for(j=0;j<9;j++)
   {
     System.out.print("  "+s[i][j]);
   }
 System.out.println();
 }

}
    }


Related Tutorials/Questions & Answers:
 

 

 

DMCA.com