SvetlanPetrova

Ski Trip SoftUni

Apr 15th, 2021
458
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class SkiTrip {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int days = Integer.parseInt(scanner.nextLine());
  7.         String room = scanner.nextLine();
  8.         String feedback = scanner.nextLine();
  9.  
  10.         double discountedCost = 0;
  11.         double finalCost = 0;
  12.         int nights = days - 1;
  13.  
  14.  
  15.         switch (room) {
  16.             case "room for one person":
  17.                 discountedCost = nights * 18;
  18.                 break;
  19.             case "apartment":
  20.                 if (nights < 10) {
  21.                     discountedCost = nights * 25 * 0.70;
  22.                 }
  23.                 else if (nights >= 10 && nights <= 15 ) {
  24.                     discountedCost = nights * 25 * 0.65;
  25.                 }
  26.                 else if (days > 15) {
  27.                     discountedCost = nights * 25 * 0.50;
  28.                 }
  29.                 break;
  30.             case "president apartment":
  31.                 if (nights < 10) {
  32.                     discountedCost = nights * 35 * 0.90;
  33.                 }
  34.                 else if (nights >= 10 && nights <= 15 ) {
  35.                     discountedCost = nights * 35 * 0.85;
  36.                 }
  37.                 else if (days > 15) {
  38.                     discountedCost = nights * 35 * 0.80;
  39.                 }
  40.                 break;
  41.         }
  42.  
  43. //        System.out.println(nights);
  44. //        System.out.println(discountedCost);
  45.  
  46.         if ("positive".equals(feedback)) {
  47.             finalCost = discountedCost * 1.25;
  48.         }
  49.         else if ("negative".equals(feedback)) {
  50.             finalCost = discountedCost * 0.90;
  51.         }
  52.  
  53.         System.out.printf("%.2f", finalCost);
  54.  
  55.     }
  56. }
  57.  
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×