In: Computer Science
Thanks for the question. Below is the code you will be needing. Let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please leave a +ve feedback : ) Let me know for any help with any other questions. Thank You! =========================================================================== import java.util.Scanner; public class RearrangeWord { public static void main(String[] args) { Scanner scanner = new Scanner(System.in); String input = ""; do { System.out.print("Enter a word (at least four characters in length): "); String word = scanner.nextLine(); String words[] = word.split("\\s+"); input = words[0]; if (input.length() < 4) { System.out.println("Word must be at least four characters in length, please try again. "); } } while (input.length() < 4); for (int row = 1; row <= input.length(); row++) { for (int col = input.length() - 1; col >= input.length() - row; col--) { System.out.print(input.charAt(col)); } System.out.println(); } } }
=================================================================