andkamen

letterCombo

Feb 18th, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.88 KB | None | 0 0
  1. package com.Ch1_ArraysAndStrings;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Pr_LetterCombo18thDec2016 {
  6.     public static void main(String[] args) {
  7.         Scanner scan = new Scanner(System.in);
  8.  
  9.         char firstChar = scan.nextLine().charAt(0);
  10.         char lastChar = scan.nextLine().charAt(0);
  11.         char ignoreChar = scan.nextLine().charAt(0);
  12.  
  13.         int count = 0;
  14.  
  15.         for (char a = firstChar; a <= lastChar; a++) {
  16.             for (char b = firstChar; b <= lastChar; b++) {
  17.                 for (char c = firstChar; c <= lastChar; c++) {
  18.                     if (a == ignoreChar || b == ignoreChar || c == ignoreChar) {
  19.                         continue;
  20.                     }
  21.                     count++;
  22.                     System.out.printf("%c%c%c ", a, b, c);
  23.                 }
  24.             }
  25.         }
  26.  
  27.         System.out.printf("%d", count);
  28.     }
  29. }
Add Comment
Please, Sign In to add comment