Advertisement
Guest User

Untitled

a guest
Feb 20th, 2018
267
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.65 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Ex3 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double budget = Double.parseDouble(scanner.nextLine());
  8. String category = scanner.nextLine();
  9. double people = Double.parseDouble(scanner.nextLine());
  10.  
  11. double leftmoney = 0;
  12. double Normal = 249.99;
  13. double VIP = 499.99;
  14.  
  15. if (category.equalsIgnoreCase("Normal")) {
  16. if (people >= 1 && people <= 4) {
  17. leftmoney = budget - (budget * 0.75);
  18. if (leftmoney >= (Normal*people)) {
  19. System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
  20. } else {
  21. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
  22. }
  23. } else if (people >= 5 && people <= 9) {
  24. leftmoney = budget - (budget * 0.60);
  25. if (leftmoney >= (Normal*people)) {
  26. System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
  27. } else {
  28. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
  29. }
  30. } else if (people >= 10 && people <= 24) {
  31. leftmoney = budget - (budget * 0.50);
  32. if (leftmoney >= (Normal*people)) {
  33. System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
  34. } else {
  35. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
  36. }
  37. } else if (people >= 25 && people <= 49) {
  38. leftmoney = budget - (budget * 0.40);
  39. if (leftmoney >= (Normal*people)) {
  40. System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
  41. } else {
  42. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
  43. }
  44. } else if (people >= 50) {
  45. leftmoney = budget - (budget * 0.25);
  46. if (leftmoney >= (Normal*people)) {
  47. System.out.printf("Yes! You have %.2f leva left.", leftmoney - Normal*people);
  48. } else {
  49. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - Normal*people));
  50. }
  51. }
  52.  
  53.  
  54. } else if (category.equalsIgnoreCase("VIP")) {
  55. if (people >= 1 && people <= 4) {
  56. leftmoney = budget - (budget * 0.75);
  57. if (leftmoney >= (VIP*people)) {
  58. System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
  59. } else {
  60. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
  61. }
  62. } else if (people >= 5 && people <= 9) {
  63. leftmoney = budget - (budget * 0.60);
  64. if (leftmoney >= (VIP*people)) {
  65. System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
  66. } else {
  67. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
  68. }
  69. } else if (people >= 10 && people <= 24) {
  70. leftmoney = budget - (budget * 0.50);
  71. if (leftmoney >= (VIP*people)) {
  72. System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
  73. } else {
  74. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
  75. }
  76. } else if (people >= 25 && people <= 49) {
  77. leftmoney = budget - (budget * 0.40);
  78. if (leftmoney >= (VIP*people)) {
  79. System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
  80. } else {
  81. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
  82. }
  83. } else if (people >= 50) {
  84. leftmoney = budget - (budget * 0.25);
  85. if (leftmoney >= (VIP*people)) {
  86. System.out.printf("Yes! You have %.2f leva left.", leftmoney - VIP*people);
  87. } else {
  88. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(leftmoney - VIP*people));
  89. }
  90. }
  91.  
  92. }
  93. }
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement