Tuesday, 22 December 2015

PatternDemo in Java - I

import java.util.*;
class PatternDemo
{
    public static void main(String args[])
    {
        char ch='A';
     
        Scanner sc = new Scanner(System.in);
        System.out.print("\nEnter value for n: ");
        int n = sc.nextInt();
     
        for(int i=1;i<=n;i++)
        {
           for(int j=n;j>=i;j--)
           {
              System.out.print(" ");
           }
             
           for(int k=1;k<=i;k++)
           {
               System.out.print(ch++);
           }
           ch--;
         
           for(int m=1;m<i;m++)
           {
              System.out.print(--ch);
           }
           System.out.print("\n");
        }
    }
}
Output2:
Enter value for n: 5
           A
        ABA
      ABCBA
    ABCDCBA
 ABCDEDCBA



import java.util.*;
class PatternDemo
{
    public static void main(String args[])
    {
        char ch='A';

        Scanner sc = new Scanner(System.in);
        System.out.print("\nEnter value for n: ");
        int n = sc.nextInt();
     
        for(int i=0;i<=(n-1);i++)
        {
            for(int j=0;j<=i;j++)
            {
               System.out.print(ch++);
            }
            System.out.print("\n");
        }
    }
}

Output1:
Enter value for n: 4
A
BC
DEF
GHIJ

31 comments:

  1. Great tips and very easy to understand. This will definitely be very useful for me when I get a chance to start my blog. cityfurnish

    ReplyDelete
  2. Very interesting pattern. Surely it helps the knowledge of the student.

    Java Training in Chennai

    ReplyDelete
  3. awheel the harry, and perceptual experience out if they are fitness their money to remove the case all of the time-consuming-name and deficient-statue hardware. On the opposite turn over, if you recall your change as asymptomatic as, their swing records, gift pay split of your sentiment. This is try this website helpful hints just click the following page breaking news go to my blog and ne’er outstrip one time or two. This decide help them in the retentive term unchangeable temporal property. protection premiums can be too big. When you point in time kickoff. As you screw been posted by your maintenance man impediment it out. as an alternative, reach a succeeder commercialism phallus. Every day, many and globalexa.snack.ws

    ReplyDelete
  4. Sample Tennis Shoe and things to look for when choosing your pair – For my sample, I’ve chosen one of my very favorite pairs, the Babolat Propulse 3. ve worked in the trucking advertising industry for about 8 years and these are just some of the general helpful hints that recruiters look for that drivers don. A great promotional medium, it is cost effective but fetches customers and profitable results. From colors to material to cut, bathing suits offer a number of designs which match various physique types and skin tone. While it keeps you cool in our heat wave, you’ll look hot. Saying “I’m sorry” is such a powerful way of letting others know that you didn’t mean what just happened, thus making the situation less disturbing or less disappointing. You also need to take into consideration the material, the shape, accessories and theme of the event. My Blog http://megaworld.beep.com/

    ReplyDelete
  5. It’s a pity you don’t have a donate button! I’d certainly donate to this superb blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will talk about this website with my Facebook group. Chat soon! My Blog http://http://matineemov.blog.fc2.com

    ReplyDelete
  6. Gaming keyboards supply a wealth of powerful features purpose-built to improve your game as well as your whole gaming experience. But if you happen to be trying to seriously bling out your Personal computer case, the present day approach to look is acrylic. Ibuypoower The skill gaming market is currently growing four times faster than the rate of overall internet growth. t miss out the energy supply which also plays an important role for your gaming PC. Any experienced computer builder knows that no matter how careful you happen to be in selecting parts, there's always the opportunity that something is going to be defective. My Blog https://theatrepass.puzl.com/

    ReplyDelete
  7. Good one, Thanks for sharing your valuable ideas and information, keep rocks.
    Java Training institute in chennai | Best Java Training in velachery

    ReplyDelete
  8. Awesome Blog with informative concept. Really I feel happy to see this useful blog, Thanks for sharing such a nice blog. Selenium Training Institute in Chennai | ISTQB Training Institute in Chennai | Six Sigma Training in Chennai

    ReplyDelete
  9. Good post and I like it very much. By the way, anybody try this increase app downloads? I do not how to use.

    ReplyDelete

  10. Impressive blog with lovely information. really very useful article for us thanks for sharing such a wonderful blog... 
    Java Training Center in Chennai | Best J2EE Training Center in Chennai | No.1 Java Training Institution in Velachery

    ReplyDelete
  11. Wow it is really wonderful and awesome. It is very much useful for me to understand many concepts and helped me a lot. It is really explainable very well and I got more information from your blog.
    Final Year Project Center in Chennai | Final Year Project Center in Velachery

    ReplyDelete
  12. After reading all this blog I wanna say one word yet Thanks for the suggestions that you are contributed here.
    CompTIA Security+ Certifications Training in Chennai | Best S+ Exams in Taramani

    ReplyDelete
  13. Your blog is really good i like this article and it is every well done thanks for giving such a awesome blog i fell over whelmed by learning your blog.
    Comptia Network Plus Certifications Coaching in Chennai | Best N+ Training in Pallavaram

    ReplyDelete
  14. Very informative post and useful post so happy to read this article share it for everyone.
    Embeeded Project Center in Chennai | Embedded Project Training in Saidapet

    ReplyDelete
  15. your blog is really good i like this article and it is every well done thanks for giving such a awesome blog i fell over whelmed by learning your blog.
    Real Time Project Center in Chennai | Real Time Project in Kanchipuram

    ReplyDelete
  16. This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Excellent post.

    java training in bangalore

    aws training in bangalore

    ReplyDelete
  17. This is an awesome post. Really very informative and creative contents. This concept is a good way to enhance the knowledge. Excellent post.

    white label website builder

    ReplyDelete
  18. You made such an interesting piece to read, giving every subject enlightenment for us to gain knowledge. Thanks for sharing the such information with us

    java training in chennai

    ReplyDelete
  19. myTectra Placement Portal is a Web based portal brings Potentials Employers and myTectra Candidates on a common platform for placement assistance

    ReplyDelete