Go to Top

Thursday 26 January 2012

Visitors Request - 3

Hi Aman !

               Thanks for posting comments ! As far as I remember, you have asked for this pattern :

# # # #
#@@@#
#@@@#
#@@@#
# # # #

(Sorry, for the bad indentation, Blogger indents are different from those in Java Terminal Window)

Here's your program : 

class pattern_40
{
 public static void print(int a)
 {
     int i,j;
     for(i=1;i<a;i++)
     System.out.print("#");
     System.out.print("\n");
     for(i=1;i<a-1;i++)
     {
         System.out.print("#");
         for(j=1;j<a-1;j++)
         System.out.print("@");
         System.out.print("#");
         System.out.print("\n");
     }
     for(i=1;i<a;i++)
     System.out.print("#");
    }
}

I have made it such that you can form a pattern for any range that you pass as a parameter into the variable "a". If you find any mistakes, or if this program is not the way you meant it to be, then please comment the same way.  Thanks for contributing a nice Java question to this blog.

Regards,
ICSE Java.

6 comments:

  1. thank u very much


    write a program to input a binary no. and convert it into decimal equivalent

    please solve it

    ReplyDelete
  2. I have already posted that program here. The link to the program is :

    http://icse-java.blogspot.com/2012/01/to-convert-binary-number-into-decimal.html

    ReplyDelete
  3. i am a student of class 10 going to give my icse this following year could you please suggest me a good book on java that deals with java from its core

    ReplyDelete
  4. Can you plase write a program to find if a number is amicable or not?

    ReplyDelete
  5. Can you plase write a program to find if a number is amicable or not?

    ReplyDelete
  6. i am a student of class 10 going to give my icse this following year could you please suggest me a good book on java that deals with java from its core

    ReplyDelete

ShareThis