Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Generate3LetterWords {
- public static void main(String[] args) {
- System.out.println("Please enter some characters: ");
- Scanner input = new Scanner(System.in);
- char[] userInput = input.nextLine().toCharArray();
- if (userInput.length == 3) {
- for (int i = 0; i < 3; i++) {
- for (int i2 = 0; i2 < 3; i2++) {
- for (int i3 = 0; i3 < 3; i3++) {
- System.out.printf("%c%c%c ", userInput[i],
- userInput[i2], userInput[i3]);
- }
- }
- }
- }
- if (userInput.length == 2) {
- for (int i = 0; i < 2; i++) {
- for (int i2 = 0; i2 < 2; i2++) {
- for (int i3 = 0; i3 < 2; i3++) {
- System.out.printf("%c%c%c ", userInput[i],
- userInput[i2], userInput[i3]);
- }
- }
- }
- }
- if (userInput.length == 1) {
- System.out.println(""+userInput[0] + userInput[0] + userInput[0]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement