desislava_topuzakova

03. Santas Holiday

Mar 29th, 2021
719
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.51 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class P03SantasHoliday {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int days = Integer.parseInt(scanner.nextLine());
  7.         String Kindroom = scanner.nextLine();
  8.         String rating = scanner.nextLine();
  9.         double price = 0;
  10.         if (days < 10)
  11.         {
  12.             switch (Kindroom) {
  13.               case "room for one person": price = (days - 1) * 18; break;
  14.               case "apartment": price = (days - 1) * 25 * 0.70;break;
  15.               case "president apartment": price = (days - 1) * 35 * 0.90;break;
  16.             }
  17.         }
  18.         else if (days <= 15)
  19.         {
  20.              switch (Kindroom) {
  21.               case "room for one person": price =(days - 1) * 18;break;
  22.               case "apartment":price =(days - 1) * 25 * 0.65;break;
  23.               case "president apartment": price =(days - 1) * 35 * 0.85;break;
  24.             };
  25.         }
  26.         else {
  27.             switch (Kindroom) {
  28.               case "room for one person": price =(days - 1) * 18;break;
  29.               case "apartment": price =(days - 1) * 25 * 0.50;break;
  30.               case "president apartment": price = (days - 1) * 35 * 0.80;break;
  31.             };
  32.         }
  33.  
  34.         if (rating.equals("positive"))
  35.         {
  36.             price = price + (price * 0.25);
  37.         }
  38.         if (rating.equals("negative"))
  39.         {
  40.             price = price - (price * 0.10);
  41.         }
  42.         System.out.printf("%.2f", price);
  43.     }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment