Advertisement
WindFell

Ticket Combination Java

Sep 11th, 2018
361
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.09 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4.  
  5. public class TicketCombination {
  6.     public static void main(String[] args) throws IOException {
  7.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  8.         int ticketCombination = Integer.parseInt(reader.readLine());
  9.         int counter = 0;
  10.  
  11.         for (char i = 'B'; i <= 'L'; i += 2) {
  12.             for (char j = 'f'; j >= 'a'; j--) {
  13.                 for (char k = 'A'; k <= 'C'; k++) {
  14.                     for (int l = 1; l <= 10; l++) {
  15.                         for (int m = 10; m >= 1; m--) {
  16.                             counter++;
  17.                             if (counter == ticketCombination) {
  18.                                 System.out.println("Ticket combination: " + i + j + k + l + m);
  19.                                 System.out.println("Prize: " + (i + j + k + l + m) + "lv.");
  20.                                 return;
  21.                             }
  22.                         }
  23.                     }
  24.                 }
  25.             }
  26.         }
  27.     }
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement