Advertisement
CoineTre

13.Ski Trip

Nov 4th, 2020 (edited)
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.30 KB | None | 0 0
  1. import java.util.Scanner;
  2. public class Test {
  3.     public static void main(String[] args) {
  4.         Scanner scanner = new Scanner(System.in);
  5.         int daysOfStay = Integer.parseInt(scanner.nextLine());
  6.         String typeOfAccommodation = scanner.nextLine();
  7.         String rate = scanner.nextLine();
  8.         daysOfStay -= 1;
  9.         double price = 0.0;
  10.         if ("room for one person".equals(typeOfAccommodation)) {
  11.             price = daysOfStay * 18;
  12.         } else if ("apartment".equals(typeOfAccommodation)) {
  13.             if (daysOfStay <= 10) {
  14.                 price = (daysOfStay * 25) * 0.7;
  15.             } else if (daysOfStay <= 15) {
  16.                 price = (daysOfStay * 25) * 0.65;
  17.             } else {
  18.                 price = (daysOfStay * 25) * 0.5;
  19.             }
  20.         } else if ("president apartment".equals(typeOfAccommodation)) {
  21.             if (daysOfStay <= 10) {
  22.                 price = (daysOfStay * 35) * 0.9;
  23.             } else if (daysOfStay <= 15) {
  24.                 price = (daysOfStay * 35) * 0.85;
  25.             } else {
  26.                 price = (daysOfStay * 35) * 0.8;
  27.             }
  28.         }
  29.         if (rate.equals("positive")) {
  30.             price *= 1.25;
  31.         } else {
  32.             price *= 0.9;
  33.         }
  34.         System.out.printf("%.2f", price);
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement