Advertisement
galinyotsev123

ProgBasicsExam28and29July2018-E06TicketCombination

Feb 23rd, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P06ticketCombination {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int count = 1;
  8. int number = Integer.parseInt(scanner.nextLine());
  9. for (char i = 'B'; i <= 'L'; i += 2) {
  10. for (char j = 'f'; j >= 'a'; j--) {
  11. for (char k = 'A'; k <= 'C'; k++) {
  12. for (int l = 1; l <= 10; l++) {
  13. for (int m = 10; m >= 1; m--) {
  14.  
  15. if (count == number) {
  16. int sum = (i + j + k) + l + m;
  17. String ticketCombination = "" + i + j +k +l + m;
  18. System.out.printf("Ticket combination: %s\n" +
  19. "Prize: %d lv.", ticketCombination, sum);
  20. return;
  21.  
  22. }
  23. count++;
  24. }
  25. }
  26. }
  27. }
  28. }
  29. }
  30. }
  31.  
  32.  
  33.  
  34. //import java.util.Scanner;
  35.  
  36. //public class Main {
  37. // public static void main(String[] args) {
  38. // Scanner scanner = new Scanner(System.in);
  39.  
  40. // int number = Integer.parseInt(scanner.nextLine());
  41. // int counter = 1;
  42.  
  43. // for (char i = 'B'; i <= 'L'; i += 2) {
  44. // for (char j = 'f'; j >= 'a'; j--) {
  45. // for (char k = 'A'; k <= 'C'; k++) {
  46. // for (int l = 1; l <= 10; l++) {
  47. // for (int m = 10; m >= 1; m--) {
  48. // if (counter == number) {
  49. // int sum = (i + j + k) + (l + m);
  50. // System.out.printf("Ticket combination: %s%s%s%d%d%n", i, j, k, l, m);
  51. // System.out.printf("Prize: %d lv.", sum);
  52. // }
  53. // counter++;
  54. // }
  55. // }
  56. // }
  57. // }
  58. // }
  59. // }
  60. // }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement