i have to print this
********
*** ***
** **
* *
** **
*** ***
********
my code is

class one
{
 public static void main(String args[])
 {
  String s1="*";int i,j;
  for(i=4;i>0;i--)
  {
     for(j=0;j<i;j++)
     {
     System.out.print(s1);
     }
  for(int k=0;k<8;k=k+2)
  {
    for(int m=0;m<k;m++)
    System.out.print(" ");
  }
  for(int n=4;n>0;i--)
  { 
   for(int l=0;l<n;l++)
   {
    System.out.print(s1);
   }
  }
  System.out.println();
  }
 }
}
Comments
Good Question... :)

i have to print this
********
*** ***
** **
* *
** **
*** ***
********
my code is

class one
{
 public static void main(String args[])
 {
  String s1="*";int i,j;
  for(i=4;i>0;i--)
  {
     for(j=0;j<i;j++)
     {
     System.out.print(s1);
     }
  for(int k=0;k<8;k=k+2)
  {
    for(int m=0;m<k;m++)
    System.out.print(" ");
  }
  for(int n=4;n>0;i--)
  { 
   for(int l=0;l<n;l++)
   {
    System.out.print(s1);
   }
  }
  System.out.println();
  }
 }
}

Put your pattern in code tags too. Spacing is stripped out otherwise. What's the question?

********
***  ***
**    **
*      *
**    **
***  ***
*******[B]*[/B]

i have to get the star pattern as given

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

i am not so clear with the for loop in this case and working with blank spaces.

Edited 7 Years Ago by poojasweetgirl: can u modify n explain this to me pls

i have to get the star pattern as given

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

i am not so clear with the for loop in this case and working with blank spaces.

try this one... i haven't made it general for any number of lines (left that part for u if u need to implement it)... just tried for the one you've showed up here.... Here it is... :)

class one
{
 public static void main(String args[])
 {
  String s1="*";
  int i,j,l=8,x=8,y=8;
  for(int n=0;n<7;n++)
  {  	
  	for(i=l/2;i>0;i--)
  	{
     	System.out.print(s1);
   	}
	for(int k=0;k<x-l;k++)
	{
	   		System.out.print(" ");
	}
	for(i=l/2;i>0;i--)
  	{  	 
     	System.out.print(s1);     	 
	}
	System.out.println(l+" "+x);
	if(y>2)
	{
		l-=2;
		y=l;
	}		
	else
		l+=2;
  }
 }
}

Hope it helps you... Mail me if you wish a friendship with me... LOL (m serious) :$:cool::D

Edited 7 Years Ago by anupam_smart: n/a

This article has been dead for over six months. Start a new discussion instead.