myrdok123

09. Ski Trip

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