desislava_topuzakova

13

May 3rd, 2021
264
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SkiTrip_10 {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6. int days = Integer.parseInt(scan.nextLine());
  7. int nights = days - 1;
  8. String room = scan.nextLine();
  9. String review = scan.nextLine();
  10. int price = 0;
  11. double discount = 0;
  12.  
  13. switch (room) {
  14. case "room for one person":
  15. price = 18;
  16. break;
  17. case "apartment":
  18. price = 25;
  19. break;
  20. case "president apartment":
  21. price = 35;
  22. break;
  23. }
  24.  
  25. if (nights < 10) {
  26. if (room.equals("apartment")) {
  27. discount = 0.3;
  28. } else if (room.equals("president apartment")) {
  29. discount = 0.1;
  30. }
  31. } else if (nights >= 10 && nights <= 15) {
  32. if (room.equals("apartment")) {
  33. discount = 0.35;
  34. } else if (room.equals("president apartment")) {
  35. discount = 0.15;
  36. }
  37. } else if (nights > 15) {
  38. if (room.equals("apartment")) {
  39. discount = 0.5;
  40. } else if (room.equals("president apartment")) {
  41. discount = 0.2;
  42. }
  43. }
  44.  
  45. double totalPrice = nights * price;
  46. double endPrice = totalPrice * (1 - discount);
  47.  
  48. if (review.equals("positive")) {
  49. endPrice *= 1.25;
  50. } else {
  51. endPrice *= 0.9;
  52. }
  53.  
  54. System.out.printf("%.2f", endPrice);
  55. }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment