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

16 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
    Replies
    1. That's so nice...Thanks Mona afrin

      Delete
  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