Advertisement
finderabc

SkiTrip

Mar 3rd, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.40 KB | None | 0 0
  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.  
  7.         int days = Integer.parseInt(scanner.nextLine());
  8.         String rooms = scanner.nextLine();
  9.         String grade = scanner.nextLine();
  10.         double nights = days - 1;
  11.         double price = 0;
  12.  
  13.         switch (rooms){
  14.             case "room for one person":
  15.                 price = nights * 18.00;
  16.                 break;
  17.             case "apartment":
  18.                 price = nights * 25.00;
  19.                 if (price < 10){
  20.                     price *= 0.7;
  21.  
  22.                 }else if (price <= 15){
  23.                     price *= 0.65;
  24.  
  25.                 }else if (price > 15){
  26.                     price *= 0.5;
  27.  
  28.                 }
  29.                 break;
  30.             case "president apartment":
  31.                 price = nights * 35.00;
  32.                 if (days < 10){
  33.                     price *= 0.9;
  34.  
  35.                 }else if (days <= 15){
  36.                     price *= 0.85;
  37.  
  38.                 }else if (days > 15){
  39.                     price *= 0.8;
  40.  
  41.                 }
  42.                 break;
  43.         }
  44.         if ("positive".equalsIgnoreCase(grade)){
  45.             price = price + (price * 0.25);
  46.         }else {
  47.             price = price - (price * 0.1);
  48.         }
  49.         System.out.println(String.format("%.2f", price));
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement