TonyTroev

Hotel

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