Lyubohd

10. Ski Trip

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