Computer Applications
Write a program in Java to display the following pattern:
A
ab
ABC
abcd
ABCDE
Answer
public class KboatPattern
{
public static void main(String args[]) {
for (int i = 65; i < 70; i++) {
for (int j = 65; j <= i; j++) {
if (i % 2 == 0)
System.out.print((char)(j+32));
else
System.out.print((char)j);
}
System.out.println();
}
}
}
Variable Description Table
Program Explanation
Output
Related Questions
Write a menu driven program to display
(i) first five upper case letters
(ii) last five lower case letters as per the user's choice.
Enter '1' to display upper case letters and enter '2' to display lower case letters.Using switch case statement, write a menu driven program to perform the following tasks:
(a) To generate and print the letters from A to Z along with their Unicode.
Letters Unicode
A 65
B 66
….. ……..
….. ……..
Z 90(b) To generate and print the letters from z to a along with their Unicode.
Letters Unicode
z 122
y 121
….. ……..
….. ……..
a 97Write a program in Java to display the following pattern:
ZYXWU
ZYXW
ZYX
ZY
ZWrite a program in Java to display the following pattern:
ABCDE
ABC
A