Print Symbol Number Formation - Java Quiz Question



Write a program to print the following formation depending upon size. Spaces at the starting of the line and spaces in between are important. Use System.out.println or System.out.print for printing.

Input (Integer) Printed Ouput
4       * 
    @ @ 
  3 3 3 
@ @ @ @
5         * 
      @ @ 
    * * * 
  4 4 4 4 
* * * * *
6           * 
        @ @ 
      * * * 
    @ @ @ @ 
  5 5 5 5 5
@ @ @ @ @ @

class PrintFormation

{    public static void main(String s[])
    {
        printFormation(5);

    }


public static void printFormation(int size)
{
//Write code here to print the required formation depending upon the size. Use System.out.println or System.out.print for printing.
}
}