Advertisement
desislava_topuzakova

03. Santas Holiday

Feb 25th, 2018
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.42 KB | None | 0 0
  1.  
  2. import java.util.Scanner;
  3.  
  4. public class demo3 {
  5.     public static void main(String[] agrs) {
  6.         Scanner scanner = new Scanner(System.in);
  7.  
  8.         int days = Integer.parseInt(scanner.nextLine());
  9.         String roomType = scanner.nextLine().toLowerCase();
  10.         String feedback = scanner.nextLine().toLowerCase();
  11.  
  12.         double pricePerNight = 0;
  13.         double discount = 0;
  14.  
  15.         if (roomType.equals("room for one person")) {
  16.             pricePerNight = 18;
  17.  
  18.         } else if (roomType.equals("apartment")) {
  19.             pricePerNight = 25;
  20.  
  21.             if (days < 10) {
  22.                 discount = 30;
  23.             } else if (days < 15) {
  24.                 discount = 35;
  25.             } else {
  26.                 discount = 50;
  27.             }
  28.  
  29.         } else if (roomType.equals("president apartment")) {
  30.             pricePerNight = 35;
  31.  
  32.             if (days < 10) {
  33.                 discount = 10;
  34.             } else if (days < 15) {
  35.                 discount = 15;
  36.             } else {
  37.                 discount = 20;
  38.             }
  39.  
  40.         }
  41.  
  42.         double totalPrice = pricePerNight * (days - 1);
  43.         double netPrice = totalPrice - (totalPrice * discount / 100);
  44.  
  45.         if (feedback.equals("positive")) {
  46.             netPrice = netPrice * 1.25;
  47.         } else if (feedback.equals("negative")) {
  48.             netPrice *= 0.9;
  49.         }
  50.  
  51.         System.out.printf("%.2f", netPrice);
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement