Computer Applications
Write a program to accept a word (say, BLUEJ) and display the pattern:
J
E E
U U U
L L L L
B B B B B
Java
Java String Handling
32 Likes
Answer
import java.util.Scanner;
public class KboatStringPattern
{
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
System.out.print("Enter a word: ");
String word = in.nextLine();
int len = word.length();
for (int i = len - 1; i >= 0; i--) {
for (int j = len - 1; j >= i; j--) {
char ch = word.charAt(i);
System.out.print(ch);
}
System.out.println();
}
}
}
Variable Description Table
Program Explanation
Output
Answered By
12 Likes
Related Questions
Write a program to display the pattern:
A B C D E
B C D E
C D E
D E
EWrite a program to accept a word (say, BLUEJ) and display the pattern:
B L U E J
L U E J
U E J
E J
JWrite a program to input a sentence. Convert the sentence into upper case letters. Display the words along with frequency of the words which have at least a pair of consecutive letters.
Sample Input: MODEM IS AN ELECTRONIC DEVICE
Sample Output:
MODEM
DEVICE
Number of words containing consecutive letters: 2Write a program to accept a word (say, BLUEJ) and display the pattern:
B L U E J
B L U E
B L U
B L
B