0
# CHALLENGE :
Write a java program to input the word in string and print it like the one given below as an example : For example: Enter the word: RED //input The pattern of RED is: R E D R E R NOTE:The space should be given in the program as above.
2 Answers
- 3
// Created by Animesh Kumar 
/*
This code takes string as input and print it given below as an example :
Example:
Input: RED
Output:
R  E  D
  R  E
    R
*/
// Challenge thread is in the comments section
import java.util.*;
import java.io.*;
public class Program
{
    public static void main(String[] args) throws IOException {
        int i,j,k,a,b;
        System.out.print("Enter words: ");
        Scanner s = new Scanner(System.in);
        BufferedReader m=new BufferedReader(new InputStreamReader(System.in));
        String arr=m.readLine();
        char[] set=arr.toCharArray();
        System.out.println(set);
        a=set.length;
        b=a;
        for(i=0;i<=a;i++){
            for(j=1;j<=i;j++){
                System.out.print(" ");
            }
            for(k=0;k<b;k++){
                System.out.print(set[k]+" ");
        }
        System.out.println("");
        b--;
    }
    }
}
// Created by Animesh Kumar
+ 2
Why does it have to be Java?



