Advertisement
silviasj

ski trip

Mar 9th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.46 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 day = Integer.parseInt(scan.nextLine());
  7.         String room = scan.nextLine();
  8.         String evaluation = scan.nextLine();
  9.         double price = 0;
  10.         double days = day - 1;
  11.         switch (room) {
  12.             case "room for one person":
  13.                 price = days * 18;
  14.                 break;
  15.             case "apartment":
  16.                 price = days * 25;
  17.                 if (days < 10) {
  18.                     price = price * 0.7;
  19.                 } else if (days >= 10 && days <= 15) {
  20.                     price = price * 0.65;
  21.                 } else if (price > 15) {
  22.                     price = price * 0.5;
  23.                 }
  24.                 break;
  25.             case "president apartment":
  26.                 price = days * 35;
  27.                 if (days < 10) {
  28.                     price = price * 0.9;
  29.                 } else if (days >= 10 && days <= 15) {
  30.                     price = price * 0.85;
  31.                 } else if (price > 15) {
  32.                     price = price * 0.8;
  33.                 }
  34.                 break;
  35.                 }
  36.         switch (evaluation) {
  37.             case "positive":
  38.                 price = price * 1.25;
  39.                 break;
  40.             case "negative":
  41.                 price = price * 0.9;
  42.         }
  43.         System.out.printf("%.2f", price);
  44.     }
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement