clipro

Untitled

Oct 24th, 2018
206
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.88 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 lab_18_hotelRoom
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // data input
  14.             var month = Console.ReadLine().ToLower();
  15.             var nights = int.Parse(Console.ReadLine());
  16.  
  17.             // variables
  18.             decimal appPrice = 0.0M;
  19.             decimal stuPrice = 0.0M;
  20.             decimal stu14Days = 1M;
  21.             decimal stu7Days = 1M;
  22.             decimal app14Days = 1M - 0.10M;
  23.             string output = string.Empty;
  24.  
  25.             // calculate price and discount based on months
  26.             switch (month)
  27.             {
  28.                 case "may":
  29.                 case "october":
  30.                     appPrice = 65.00M;
  31.                     stuPrice = 50.00M;
  32.                     stu7Days = 1M - 0.05M;
  33.                     stu14Days = 1M - 0.30M;
  34.                     break;
  35.                 case "june":
  36.                 case "september":
  37.                     appPrice = 68.70M;
  38.                     stuPrice = 75.20M;
  39.                     stu14Days = 1M - 0.20M;
  40.                     break;
  41.                 case "july":
  42.                 case "august":
  43.                     appPrice = 77.00M;
  44.                     stuPrice = 76.00M;
  45.                     break;
  46.             }
  47.  
  48.             // calculate total price depending on number of nights
  49.             if (nights > 14)
  50.             {
  51.                 appPrice *= app14Days;
  52.                 stuPrice *= stu14Days;
  53.             }
  54.             else if (nights > 7)
  55.             {
  56.                 stuPrice *= stu7Days;
  57.             }
  58.  
  59.             output = string.Format("Apartment: {0:F2} lv. \nStudio: {1:F2} lv.",
  60.                 appPrice * nights, stuPrice * nights);
  61.  
  62.             Console.WriteLine(output);
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment