skipter

Letters Combination - Java Basics Loops

Apr 29th, 2017
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.79 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class FOX {
  4.     public static void main(String[] args) {
  5.  
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.       char firstChar = input.nextLine().charAt(0);
  9.       char secondChar = input.nextLine().charAt(0);
  10.       char thurdChar = input.nextLine().charAt(0);
  11.       int counter = 0;
  12.  
  13.         for (char i = firstChar; i <= secondChar ; i++) {
  14.             for (char j = firstChar; j <= secondChar; j++) {
  15.                 for (char k = firstChar; k <= secondChar; k++) {
  16.                     if (!(i == thurdChar || j == thurdChar || k == thurdChar)) {
  17.                         counter++;
  18.                         System.out.printf("%s%s%s ", i, j, k);
  19.                     }
  20.                 }
  21.             }
  22.         }
  23.         System.out.println(counter);
  24.     }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment