WAP in JAVA to print a pattern of diamond
Plz answer fast
Answers
CODE :
class perfect_diamond
{
void main()
{
System.out.println(" $");
for(int a=1;a<=5;a++)
{
for(int b=5;b>=a;b--)
{
System.out.print(" ");
}
for(int c=1;c<=a;c++)
{
System.out.print('$'+" ");
}
for(int d=1;d<=a;d++)
{
System.out.print('$'+" ");
}
System.out.println();
}
System.out.println("$ $ $ $ $ $ $ $ $ $ $ $");
for(int a=5;a>=1;a--)
{
for(int b=5;b>=a;b--)
{
System.out.print(" ");
}
for(int c=1;c<=a;c++)
{
System.out.print('$'+" ");
}
for(int d=1;d<=a;d++)
{
System.out.print('$'+" ");
}
System.out.println();
}
System.out.println(" $");
}
}
-------------------------------------------------------------------------------
OUTPUT : in the attachment
Hope it helps :-)
______________________________________________________________________