Advertisement
delqn_marinov

SkiTrip

Feb 26th, 2020
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SkiTrip {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int daysInBansko = Integer.parseInt(scan.nextLine());
  7. String roomType = scan.nextLine();
  8. String mark = scan.nextLine();
  9.  
  10. int nights = daysInBansko - 1;
  11. double priceOfVacation = 0;
  12. switch (roomType) {
  13. case "room for one person":
  14. priceOfVacation = nights * 18;
  15. break;
  16. case "apartment":
  17. priceOfVacation = nights * 25;
  18. if (nights < 10) {
  19. priceOfVacation = priceOfVacation * 0.7;
  20. } else if (nights >= 10 && nights <= 15) {
  21. priceOfVacation = priceOfVacation * 0.65;
  22. } else if (nights > 15) {
  23. priceOfVacation = priceOfVacation * 0.5;
  24. }
  25. break;
  26. case "president apartment":
  27. priceOfVacation = nights * 35;
  28. if (nights < 10) {
  29. priceOfVacation = priceOfVacation * 0.9;
  30. } else if (nights > 10 && nights <= 15) {
  31. priceOfVacation = priceOfVacation * 0.85;
  32. } else if (nights > 15) {
  33. priceOfVacation = priceOfVacation * 0.80;
  34. break;
  35. }
  36.  
  37. if (mark.equals("positive")) {
  38. priceOfVacation = priceOfVacation + 0.25 * priceOfVacation;
  39. } else {
  40. priceOfVacation = priceOfVacation * 0.9;
  41. }
  42. System.out.printf("%.2f", priceOfVacation);
  43.  
  44. }
  45. }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement