Advertisement
Dido09

MatchTickets

Jan 2nd, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.62 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class MatchTickets {
  4.  
  5. public static void main(String[] args) {
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. double vipPrice = 499.99;
  9. double normalPrice = 249.99;
  10.  
  11. int budjet = Integer.parseInt(scanner.nextLine());
  12. String category = scanner.nextLine();
  13. int peopleNumber= Integer.parseInt(scanner.nextLine());
  14.  
  15. double moneyForTickets = -1.0;
  16. double price = -1.0;
  17. double difference = -1.0;
  18.  
  19. boolean from1To4 = peopleNumber >= 1 && peopleNumber <=4;
  20. boolean from5To9 = peopleNumber >= 5 && peopleNumber <=9;
  21. boolean from10To24 = peopleNumber >= 10 && peopleNumber <=24;
  22. boolean from25To49 = peopleNumber >= 25 && peopleNumber <=49;
  23. boolean over50 = peopleNumber >= 50;
  24.  
  25. if (category.equals("Normal")) {
  26. if (from1To4) {
  27. moneyForTickets = budjet - (budjet * 0.75);
  28. price = peopleNumber * normalPrice;
  29. if (price <= moneyForTickets) {
  30. difference = moneyForTickets - price;
  31. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  32. } else {
  33. difference = price - moneyForTickets;
  34. System.out.printf("Not enough money! You need %.2f leva.", difference);
  35. }
  36. } else if (from5To9) {
  37. moneyForTickets = budjet - (budjet * 0.60);
  38. price = peopleNumber * normalPrice;
  39. if (price <= moneyForTickets) {
  40. difference = moneyForTickets - price;
  41. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  42. } else {
  43. difference = price - moneyForTickets;
  44. System.out.printf("Not enough money! You need %.2f leva.", difference);
  45. }
  46. } else if (from10To24) {
  47. moneyForTickets = budjet - (budjet * 0.50);
  48. price = peopleNumber * normalPrice;
  49. if (price <= moneyForTickets) {
  50. difference = moneyForTickets - price;
  51. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  52. } else {
  53. difference = price - moneyForTickets;
  54. System.out.printf("Not enough money! You need %.2f leva.", difference);
  55. }
  56. } else if (from25To49) {
  57. moneyForTickets = budjet - (budjet * 0.40);
  58. price = peopleNumber * normalPrice;
  59. if (price <= moneyForTickets) {
  60. difference = moneyForTickets - price;
  61. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  62. } else {
  63. difference = price - moneyForTickets;
  64. System.out.printf("Not enough money! You need %.2f leva.", difference);
  65. }
  66. } else if (over50) {
  67. moneyForTickets = budjet - (budjet * 0.25);
  68. price = peopleNumber * normalPrice;
  69. if (price <= moneyForTickets) {
  70. difference = moneyForTickets - price;
  71. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  72. } else {
  73. difference = price - moneyForTickets;
  74. System.out.printf("Not enough money! You need %.2f leva.", difference);
  75. }
  76. }
  77. } else if (category.equals("VIP")) {
  78. if (from1To4) {
  79. moneyForTickets = budjet - (budjet * 0.75);
  80. price = peopleNumber * vipPrice;
  81. if (price <= moneyForTickets) {
  82. difference = moneyForTickets - price;
  83. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  84. } else {
  85. difference = price - moneyForTickets;
  86. System.out.printf("Not enough money! You need %.2f leva.", difference);
  87. }
  88. } else if (from5To9) {
  89. moneyForTickets = budjet - (budjet * 0.60);
  90. price = peopleNumber * vipPrice;
  91. if (price <= moneyForTickets) {
  92. difference = moneyForTickets - price;
  93. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  94. } else {
  95. difference = price - moneyForTickets;
  96. System.out.printf("Not enough money! You need %.2f leva.", difference);
  97. }
  98. } else if (from10To24) {
  99. moneyForTickets = budjet - (budjet * 0.50);
  100. price = peopleNumber * vipPrice;
  101. if (price <= moneyForTickets) {
  102. difference = moneyForTickets - price;
  103. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  104. } else {
  105. difference = price - moneyForTickets;
  106. System.out.printf("Not enough money! You need %.2f leva.", difference);
  107. }
  108. } else if (from25To49) {
  109. moneyForTickets = budjet - (budjet * 0.40);
  110. price = peopleNumber * vipPrice;
  111. if (price <= moneyForTickets) {
  112. difference = moneyForTickets - price;
  113. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  114. } else {
  115. difference = price - moneyForTickets;
  116. System.out.printf("Not enough money! You need %.2f leva.", difference);
  117. }
  118. } else if (over50) {
  119. moneyForTickets = budjet - (budjet * 0.25);
  120. price = peopleNumber * vipPrice;
  121. if (price <= moneyForTickets) {
  122. difference = moneyForTickets - price;
  123. System.out.printf("Yes! You have %.2f leva left.", Math.abs(difference));
  124. } else {
  125. difference = price - moneyForTickets;
  126. System.out.printf("Not enough money! You need %.2f leva.", difference);
  127. }
  128. }
  129. }
  130. }
  131.  
  132. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement