Advertisement
ibakyrdjiev

3words

Sep 16th, 2014
236
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.88 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Generate3LetterWords {
  4. public static void main(String[] args) {
  5. System.out.println("Please enter some characters: ");
  6. Scanner input = new Scanner(System.in);
  7. char[] userInput = input.nextLine().toCharArray();
  8. if (userInput.length == 3) {
  9. for (int i = 0; i < 3; i++) {
  10. for (int i2 = 0; i2 < 3; i2++) {
  11. for (int i3 = 0; i3 < 3; i3++) {
  12. System.out.printf("%c%c%c ", userInput[i],
  13. userInput[i2], userInput[i3]);
  14. }
  15. }
  16. }
  17.  
  18. }
  19. if (userInput.length == 2) {
  20. for (int i = 0; i < 2; i++) {
  21. for (int i2 = 0; i2 < 2; i2++) {
  22. for (int i3 = 0; i3 < 2; i3++) {
  23. System.out.printf("%c%c%c ", userInput[i],
  24. userInput[i2], userInput[i3]);
  25. }
  26. }
  27. }
  28. }
  29.  
  30. if (userInput.length == 1) {
  31. System.out.println(""+userInput[0] + userInput[0] + userInput[0]);
  32. }
  33. }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement