String Pattern

A

AB

ABC

ABCD

ABCDE

import java.util.*;

public class StringPattern1

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

char ch='A';

int ascii= (int) ch;

System.out.println(" How many Rows:");

int n=sc.nextInt();

System.out.println(" The Patternn is : ");

for(int i=ascii;i<ascii+n;i++)

{

for(int j=ascii;j<i;j++)

{

System.out.print((char)j);

}

System.out.println();

}

}

}

Print the bellow Pattern:-

C

O O

M M M

P P P P

U U U U U

T T T T T T

E E E E E E E

R R R R R R R R

S S S S S S S S S S


import java.util.Scanner;

public class StringPatter2

{

public static void main()

{

Scanner sc=new Scanner (System.in);

System.out.println("Enter a string to make a pyramid");

String str=sc.nextLine();

for (int i =0;i<str.length();i++)

{

for (int j=0;j<=i;j++)

{

//int alphabet =(int)str.charAt(j);

int a =(int)str.charAt(i);

System.out.print((char)(a));

}

System.out.println();

}

}

}


/**

ABCDE

BCDE

CDE

DE

F

*/

import java.util.*;

public class StringPatter3

{

public static void main(String args[])

{

Scanner sc =new Scanner(System.in);

System.out.println("enter how many steps:");

int n= sc.nextInt();

char ch='A', ch1;

for(int i=n;i>=0;i--)

{

ch1=ch;

for(int j=0;j<=i;j++)

{

System.out.print(ch1);

ch1++;

}

System.out.println(" ");

ch++;

}

}

}

Enter no of terms:

5

ABCDE

ABCD

ABC

AB

A


import java.util.*;

public class StringPatter4

{

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

int n,k;

System.out.println("Enter no of terms:");

n=sc.nextInt();

k=n;

char ch='A';

for(int i=0;i<n;i++)

{

ch='A';

for(int j=0;j<k;j++)

{

System.out.print(ch++);

}

k--;

System.out.println();

}

}

}