BubaLazi

06.HotelDiscount

Jun 5th, 2017
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SomeHomeworks
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var month = Console.ReadLine().ToLower();
  14.             var nights = int.Parse(Console.ReadLine());
  15.  
  16.             var studioPrice = 0.00;
  17.             var doublePrice = 0.00;
  18.             var suitePrice = 0.00;
  19.  
  20.             switch(month)
  21.             {
  22.                 case "may":
  23.                 case "october":
  24.                     studioPrice = 50;
  25.                     doublePrice = 65;
  26.                     suitePrice = 75;
  27.                     break;
  28.                 case "june":
  29.                 case "september":
  30.                     studioPrice = 60;
  31.                     doublePrice = 72;
  32.                     suitePrice = 82;
  33.                     break;
  34.                 case "july":
  35.                 case "august":
  36.                 case "december":
  37.                     studioPrice = 68;
  38.                     doublePrice = 77;
  39.                     suitePrice = 89;
  40.                     break;
  41.                    
  42.             }
  43.  
  44.             if (nights > 7 && (month == "may" || month == "october"))
  45.             {
  46.                 studioPrice *= 0.95;
  47.             }
  48.             else if(nights > 14 && (month == "june" || month == "september"))
  49.             {
  50.                 doublePrice *= 0.9;
  51.             }
  52.             else if(nights > 14 && (month == "july" || month == "august" || month == "december"))
  53.             {
  54.                 suitePrice *= 0.85;
  55.             }
  56.            
  57.             var totalStudioPrice = studioPrice * nights;
  58.             var totalDoublePrice = doublePrice * nights;
  59.             var totalSuitePrice = suitePrice * nights;
  60.  
  61.             if (nights > 7 && (month == "september" || month == "october"))
  62.             {
  63.                 totalStudioPrice -= studioPrice;
  64.                
  65.             }
  66.  
  67.             Console.WriteLine($"Studio: {totalStudioPrice:F2} lv.");
  68.             Console.WriteLine($"Double: {totalDoublePrice:F2} lv.");
  69.             Console.WriteLine($"Suite: {totalSuitePrice:F2} lv.");
  70.  
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment