TheBulgarianWolf

Combinations of letters

Mar 24th, 2020
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.94 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Main
  3. {
  4.     public static void main(String[] args) {
  5.         Scanner sc = new Scanner(System.in);
  6.         //Reading the characters
  7.         int count = 0;
  8.         System.out.print("Enter the start letter: ");
  9.         char startLetter = sc.next().charAt(0);
  10.         System.out.print("Enter the end letter: ");
  11.         char endLetter = sc.next().charAt(0);
  12.         System.out.print("Enter the letter that you don't want to be included: ");
  13.         char notIncludedLetter = sc.next().charAt(0);
  14.         for(char i = startLetter;i<=endLetter;i++){
  15.             if(i != notIncludedLetter){
  16.              for(char l = startLetter;l<=endLetter;l++){
  17.                if(l != notIncludedLetter){
  18.                for(char u = startLetter;u<=endLetter;u++){
  19.                    if(u != notIncludedLetter){
  20.                         System.out.print(i+ "" + l+"" +u + " ");
  21.                         count++;
  22.                    }
  23.                   }
  24.                }    
  25.                
  26.              }
  27.             }
  28.         }
  29.         System.out.print(" " + count);
  30.     }
  31. }
Add Comment
Please, Sign In to add comment