Advertisement
knoteva

Untitled

Nov 4th, 2019
300
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 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 room = scanner.nextLine();
  9.         String rating = scanner.nextLine();
  10.  
  11.         double priceOne = 18.00;
  12.         double priceTwo = 25.00;
  13.         double priceThree = 35.00;
  14.  
  15.         double price = 0.00;
  16.  
  17.         double nights = days - 1;
  18.  
  19.         if (room.equals("room for one person")) {
  20.             if (nights < 10) {
  21.                 price = priceOne * nights;
  22.             } else if (nights <= 15) {
  23.                 price = priceOne * nights;
  24.             } else {
  25.                 price = priceOne * nights;
  26.             }
  27.         } else if (room.equals("apartment")) {
  28.             if (nights < 10) {
  29.                 price = priceTwo * nights * 0.70;
  30.             } else if (nights <= 15) {
  31.                 price = priceTwo * nights * 0.65;
  32.             } else {
  33.                 price = priceTwo * nights * 0.50;
  34.             }
  35.         } else if (room.equals("president apartment")) {
  36.             if (nights < 10) {
  37.                 price = priceThree * nights * 0.90;
  38.             } else if (nights <= 15) {
  39.                 price = priceThree * nights * 0.85;
  40.             } else {
  41.                 price = priceThree * nights * 0.80;
  42.             }
  43.         }
  44.  
  45.         if (rating.equals("positive")) {
  46.             price = price + (0.25 * price);
  47.         } else if (rating.equals("negative")) {
  48.             price = price - (0.10 * price);
  49.         }
  50.      
  51.             System.out.printf("%.2f", price);      
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement