Advertisement
uktcar

03.2.09SkiTrip

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