package demo;
import java.util.Scanner;
public class CharacterPattern
{
public static void main(String[] args)
{
char ch, r, c;
System.out.println("Enter last pyramid character : ");
Scanner sc = new Scanner(System.in);
ch = sc.next().charAt(0);
if (ch >= 'a' && ch <= 'z') {
ch = (char)(ch - 32);
}
for (r = 'A'; r <= ch; r++) {
for (c = 'A'; c <= r; c++) {
System.out.print(r + "" + (char)(r + 32) + " ");
}
System.out.println();
}
}
}
Output:
Enter last pyramid character :
e
Aa
Bb Bb
Cc Cc Cc
Dd Dd Dd Dd
Ee Ee Ee Ee Ee
BUILD SUCCESSFUL (total time: 7 seconds)
|
No comments:
Post a Comment