Advertisement
yanass

Untitled

Apr 3rd, 2019
425
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.34 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 hotel_room
  8. {
  9.     class Program
  10.     {
  11.         static double PricePerNightStudio(string month)
  12.         {
  13.             double priceStudio = 0;
  14.             if (month == "May" || month == "October")
  15.             {
  16.                 priceStudio = 50.00;
  17.             }
  18.             else if (month == "June" || month == "September")
  19.             {
  20.                 priceStudio = 75.20;
  21.             }
  22.             else if (month == "July" || month == "August")
  23.             {
  24.                 priceStudio = 76.00;
  25.             }
  26.             return priceStudio;
  27.         }
  28.  
  29.         static double PricePerNightApartment(string month)
  30.         {
  31.             double priceApartment = 0;
  32.             if (month == "May" || month == "October")
  33.             {
  34.                 priceApartment = 65.00;
  35.             }
  36.             else if (month == "June" || month == "September")
  37.             {
  38.                 priceApartment = 68.70;
  39.             }
  40.             else if (month == "July" || month == "August")
  41.             {
  42.                 priceApartment = 77.00;
  43.             }
  44.             return priceApartment;
  45.         }
  46.  
  47.         static double PriceWithDiscountStudio(string month, double nights, double totalPrice)
  48.         {
  49.             double priceWithDiscount = 0;
  50.             if ((nights > 7 && nights <= 14) && (month == "May" || month == "October"))
  51.             {
  52.                 priceWithDiscount = totalPrice - totalPrice * 0.05;
  53.             }
  54.             if (nights > 14 && (month == "May" || month == "October"))
  55.             {
  56.                 priceWithDiscount = totalPrice - totalPrice * 0.30;
  57.             }
  58.             else if (nights > 14 && (month == "June" || month == "September"))
  59.             {
  60.                 priceWithDiscount = totalPrice - totalPrice * 0.20;
  61.             }
  62.             else if (nights == 0)
  63.             {
  64.                 priceWithDiscount = 0.00;
  65.             }
  66.             else
  67.                 priceWithDiscount = totalPrice;
  68.             return priceWithDiscount;
  69.         }
  70.         static double PriceWithDiscountApartment(string month, double nights, double totalPrice)
  71.         {
  72.             double priceWithDiscount = 0;
  73.  
  74.             if (nights > 14)
  75.             {
  76.                 priceWithDiscount = totalPrice - totalPrice * 0.10;
  77.             }
  78.             else if (nights == 0)
  79.             {
  80.                 priceWithDiscount = 0.00;
  81.             }
  82.             else
  83.                 priceWithDiscount = totalPrice;
  84.             return priceWithDiscount;
  85.         }
  86.  
  87.         static void Main(string[] args)
  88.         {
  89.             //May, June, July, August, September или October
  90.             string month = Console.ReadLine();
  91.             int nights = int.Parse(Console.ReadLine());
  92.  
  93.             double priceStudio = nights * PricePerNightStudio(month);
  94.             double priceApartment = nights * PricePerNightApartment(month);
  95.  
  96.             priceStudio = PriceWithDiscountStudio(month, nights, priceStudio);
  97.             priceApartment = PriceWithDiscountApartment(month, nights, priceApartment);
  98.  
  99.             Console.WriteLine($"Apartment: {Math.Round(priceApartment, 2):f2} lv.");
  100.             Console.WriteLine($"Studio: {Math.Round(priceStudio, 2):f2} lv.");
  101.  
  102.  
  103.         }
  104.     }
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement