Advertisement
AngelKejov

Untitled

Mar 20th, 2021
85
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package com.company;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class SkiTrip {
  6.  
  7.     public static void main(String[] args) {
  8.         Scanner sc = new Scanner(System.in);
  9.  
  10.         double roomForOne = 18.00;
  11.         double apartment = 25.00;
  12.         double presidentApartment = 35.00;
  13.  
  14.         int days = Integer.parseInt(sc.nextLine());
  15.         String roomType = sc.nextLine();
  16.         String grade = sc.nextLine();
  17.  
  18.         int nights = days - 1;
  19.         double price = 0;
  20.         if (roomType.equals("room for one person")) {
  21.             price = nights * roomForOne;
  22.  
  23.             if (grade.equals("positive")) {
  24.                 price = price + (price * 0.25);
  25.             } else if (grade.equals("negative")) {
  26.                 price = price - (price * 0.1);
  27.             }
  28.         } else if (roomType.equals("apartment")) {
  29.             price = nights * apartment;
  30.             if (days < 10) {
  31.                 price = price - (price * 0.3);
  32.             } else if (days > 10 && days <= 15) {
  33.                 price = price - (price * 0.35);
  34.             } else if (days > 15) {
  35.                 price = price - (price * 0.5);
  36.             }
  37.  
  38.             if (grade.equals("positive")) {
  39.                 price = price + (price * 0.25);
  40.             } else if (grade.equals("negative")) {
  41.                 price = price - (price * 0.1);
  42.             }
  43.         } else if (roomType.equals("president apartment")) {
  44.             price = nights * presidentApartment;
  45.             if (days < 10) {
  46.                 price = price - (price * 0.1);
  47.             } else if (days > 10 && days <= 15) {
  48.                 price = price - (price * 0.15);
  49.             } else if (days > 15) {
  50.                 price = price - (price * 0.20);
  51.             }
  52.  
  53.             if (grade.equals("positive")) {
  54.                 price = price + (price * 0.25);
  55.             } else if (grade.equals("negative")) {
  56.                 price = price - (price * 0.1);
  57.             }
  58.         }
  59.  
  60.         System.out.printf("%.2f", price);
  61.     }
  62. }
  63.  
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement