Advertisement
JAVANHEL

Untitled

Nov 21st, 2018
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class honeymoon {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. double budget = Double.parseDouble(scanner.nextLine());
  8. String destination = scanner.nextLine();
  9. int countDays = Integer.parseInt(scanner.nextLine());
  10. double total = 0;
  11.  
  12. double kairo = 2 * 250.0; //+ 600;
  13. double parij = 2 * 150.0; //+ 350;
  14. double lima = 2 * 400.0; //+ 850;
  15. double newYork = 2 * 300.0; //+ 650;
  16. double tokyo = 2 * 350.0; //+ 700;
  17.  
  18. if (destination.equals("Cairo")) {
  19. if (countDays >= 1 && countDays <= 4) {
  20. total = (kairo*countDays+600)-((kairo*countDays+600)*3/100);
  21. } else if (countDays >= 5 && countDays <= 9) {
  22. total = (kairo*countDays+600)-((kairo*countDays+600 * 5 / 100.0));
  23. } else if (countDays >= 10 && countDays <= 24) {
  24. total = (kairo*countDays+600)-((kairo*countDays+600* 10 / 100.0));
  25. } else if (countDays >= 25 && countDays <= 49) {
  26. total =(kairo*countDays+600)-((kairo*countDays+600* 17 / 100.0));
  27. } else if(countDays>=50) {
  28. total = (kairo*countDays+600)-((kairo*countDays+600 * 30 / 100.0));
  29. }
  30. } else if (destination.equals("Paris")) {
  31. if (countDays >= 1 && countDays <= 4) {
  32. total = parij*countDays+350;
  33. } else if (countDays >= 5 && countDays <= 9) {
  34. total = (parij*countDays+350)- ((parij*countDays+350) * 7 / 100.0);
  35. } else if (countDays >= 10 && countDays <= 24) {
  36. total = (parij*countDays+350)- ((parij*countDays+350) * 12 / 100.0);
  37. } else if (countDays >= 25 && countDays <= 49) {
  38. total = (parij*countDays+350)- ((parij*countDays+350)*22 / 100.0);
  39. } else if(countDays>=50) {
  40. total = (parij*countDays+350)- ((parij*countDays+350)* 30 / 100.0);
  41. }
  42.  
  43. } else if (destination.equals("Lima")) {
  44. if (countDays >= 1 && countDays <= 24) {
  45. total = lima*countDays+850;
  46. } else if (countDays >= 25 && countDays <= 49) {
  47. total = (lima*countDays+850)- ((lima*countDays+850) * 19 / 100.0);
  48. } else if(countDays>=50) {
  49. total = (lima*countDays+850)- ((lima*countDays+850)* 30 / 100.0);
  50. }
  51. } else if (destination.equals("New York")) {
  52. if (countDays >= 1 && countDays <= 4) {
  53. total = (newYork*countDays+650)- ((newYork*countDays+650) * 3 / 100.0);
  54. } else if (countDays >= 5 && countDays <= 9) {
  55. total = (newYork*countDays+650)- ((newYork*countDays+650) * (5 / 100.0));
  56. } else if (countDays >= 10 && countDays <= 24) {
  57. total = (newYork*countDays+650)- ((newYork*countDays+650)* 12 / 100.0);
  58. } else if (countDays >= 25 && countDays <= 49) {
  59. total = (newYork*countDays+650)- ((newYork*countDays+650) * (19 / 100.0));
  60. } else if(countDays>=50) {
  61. total = (newYork*countDays+650)- ((newYork*countDays+650) * 30 / 100.0);
  62. }
  63. } else if (destination.equals("Tokyo")) {
  64. if (countDays >= 1 && countDays <= 9) {
  65. total = tokyo*countDays+700;
  66. } else if (countDays >= 10 && countDays <= 24) {
  67. total = (tokyo*countDays+700)- ((tokyo*countDays+700) * 12 / 100.0);
  68. } else if (countDays >= 25 && countDays <= 49) {
  69. total = (tokyo*countDays+700)- ((tokyo*countDays+700) * 17 / 100.0);
  70. } else if(countDays>=50) {
  71. total = (tokyo*countDays+700)- ((tokyo*countDays+700)* (30 / 100.0));
  72. }
  73. }
  74.  
  75. double diff = budget - total;
  76. if (budget > total) {
  77. System.out.printf("Yes! You have %.2f leva left.",diff);
  78. } else {
  79. System.out.printf("Not enough money! You need %.2f leva.", Math.abs(diff));
  80. }
  81. }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement