Advertisement
Angel_Kalinkov

C#ConditionalStatementsAndLoops-Exercises-Hotel_AngelKalinko

Jan 29th, 2018
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.81 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Hotel {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         String month = scanner.nextLine().toLowerCase();
  8.         short nights = Short.parseShort(scanner.nextLine());
  9.  
  10.         float studioPrice = 0.0f;
  11.         float doublePrice = 0.0f;
  12.         float suitePrice = 0.0f;
  13.  
  14.         switch (month) {
  15.             case "may":
  16.             case "october":
  17.                 studioPrice = 50f;
  18.                 doublePrice = 65f;
  19.                 suitePrice = 75f;
  20.                 if (nights > 7) {
  21.                     studioPrice *= 0.95f;
  22.                 }
  23.                 break;
  24.             case "june":
  25.             case "september":
  26.                 studioPrice = 60f;
  27.                 doublePrice = 72f;
  28.                 suitePrice = 82f;
  29.                 if (nights > 14) {
  30.                     doublePrice *= 0.9f;
  31.                 }
  32.                 break;
  33.             case "july":
  34.             case "august":
  35.             case "december":
  36.                 studioPrice = 68f;
  37.                 doublePrice = 77f;
  38.                 suitePrice = 89f;
  39.                 if (nights > 14) {
  40.                     suitePrice *= 0.85f;
  41.                 }
  42.                 break;
  43.             default:
  44.                 break;
  45.         }
  46.         float moneyForStudio = studioPrice * nights;
  47.         float moneyForDouble = doublePrice * nights;
  48.         float moneyForSuite = suitePrice * nights;
  49.  
  50.         if (nights > 7 && (month.equals("september") || month.equals("october"))) {
  51.             moneyForStudio = studioPrice * (nights - 1);
  52.         }
  53.         System.out.printf("Studio: %.2f lv.\n", moneyForStudio);
  54.         System.out.printf("Double: %.2f lv.\n", moneyForDouble);
  55.         System.out.printf("Suite: %.2f lv.", moneyForSuite);
  56.     }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement