Advertisement
Lyubohd

Untitled

Sep 23rd, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.84 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hotel {
  4.     public static void main(String[] args) {
  5.         Scanner scan = new Scanner(System.in);
  6.  
  7.         String month = scan.nextLine();
  8.         int nightsCount = Integer.parseInt(scan.nextLine());
  9.  
  10.         double studioPrice = 0;
  11.         double doublePrice = 0;
  12.         double suitePrice = 0;
  13.  
  14.  
  15.         switch (month) {
  16.             case "May":
  17.             case "October":
  18.                 studioPrice = 50 * nightsCount;
  19.                 doublePrice = 65 * nightsCount;
  20.                 suitePrice = 75 * nightsCount;
  21.                 if (nightsCount > 7) {
  22.                     studioPrice = studioPrice * 0.95;
  23.                 }
  24.                 break;
  25.             case "June":
  26.             case "September":
  27.                 studioPrice = 60 * nightsCount;
  28.                 doublePrice = 72 * nightsCount;
  29.                 suitePrice = 82 * nightsCount;
  30.                 if (nightsCount > 14) {
  31.                     doublePrice = doublePrice * 0.9;
  32.                 }
  33.                 break;
  34.             case "July":
  35.             case "August":
  36.             case "December":
  37.                 studioPrice = 68 * nightsCount;
  38.                 doublePrice = 77 * nightsCount;
  39.                 suitePrice = 89 * nightsCount;
  40.                 if (nightsCount > 14) {
  41.                     suitePrice = suitePrice * 0.85;
  42.                 }
  43.                 break;
  44.         }
  45.         if (month.equals("September") && nightsCount > 7) {
  46.             studioPrice -= 60;
  47.         }
  48.         if (month.equals("October") && nightsCount > 7) {
  49.             studioPrice -= 50 * 0.95;
  50.         }
  51.         System.out.println(String.format("Studio: %.2f lv.", studioPrice));
  52.         System.out.println(String.format("Double: %.2f lv.", doublePrice));
  53.         System.out.println(String.format("Suite: %.2f lv.", suitePrice));
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement