Advertisement
vdjalov

Untitled

Jul 30th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TicketCombination {
  4.  
  5.     public static void main(String[] args) {
  6.        
  7.             Scanner scanner = new Scanner(System.in);
  8.            
  9.             int input = Integer.parseInt(scanner.nextLine());
  10.             int count = 0;
  11.             int prize = 0;
  12.            
  13.                 for(int a = 'B'; a <= 'L'; a+=2){
  14.                     for(int b = 'f'; b >= 'a'; b--){
  15.                         for(int c = 'A';c <= 'C'; c++){
  16.                             for(int d = 1; d <= 10; d++){
  17.                                 for(int e = 10; e >= 1; e--){
  18.                                     count++;
  19.                                     if(count == input){
  20.                                         System.out.println("Ticket combination: " + (char)a + (char)b + (char)c + d + e);
  21.                                         prize = a + b + c + d + e;
  22.                                         System.out.println("Prize: " + prize + " lv.");
  23.                                         break;
  24.                                     }
  25.                                    
  26.                                 }
  27.                                 if(count == input){
  28.                                     break;
  29.                                 }
  30.                             }
  31.                             if(count == input){
  32.                                 break;
  33.                             }
  34.                         }
  35.                         if(count == input){
  36.                             break;
  37.                         }
  38.                     }
  39.                     if(count == input){
  40.                         break;
  41.                     }
  42.                 }
  43.                
  44.        
  45.         scanner.close();
  46.         // "breaks" -  are not necessary you can let it roll.....
  47.  
  48.     }
  49.  
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement