Anzzhhela98

ski

Jun 3rd, 2020
148
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.Linq.Expressions;
  3.  
  4. namespace gf
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             //Първи ред -дни за престой -цяло число в интервала[0...365]
  11.             // Втори ред -вид помещение - " room for one person", " apartment & quot; или & quot; president apartment"
  12.             // Трети ред -оценка - " positive & quot; или & quot; negative & quot;
  13.             double day = double.Parse(Console.ReadLine());
  14.             string type = Console.ReadLine();
  15.             string evaluation = Console.ReadLine();
  16.  
  17.             double pricePerNight = 0;
  18.             double discount = 0;
  19.  
  20.             if (type == "room for one person")
  21.             {
  22.                 pricePerNight = 18;
  23.             }
  24.             else if (type =="apartment")
  25.             {
  26.                 pricePerNight = 25;
  27.                 if (day<10)
  28.                 {
  29.                     discount = 0.30;
  30.                 }
  31.                 else if (day >10 && day <15)
  32.                 {
  33.                     discount = 0.35;
  34.                 }
  35.                 else if (day >15)
  36.                 {
  37.                     discount = 0.50;
  38.                 }
  39.             }
  40.             else if (type == "president apartment")
  41.             {
  42.                 pricePerNight = 35;
  43.                 if (day < 10)
  44.                 {
  45.                     discount = 0.10;
  46.                 }
  47.                 else if (day > 10 && day < 15)
  48.                 {
  49.                     discount = 0.15;
  50.                 }
  51.                 else if (day > 15)
  52.                 {
  53.                     discount = 0.20;
  54.                 }
  55.             }
  56.             double totalPrice = pricePerNight * (day - 1);
  57.             totalPrice -= totalPrice * discount;
  58.             if (evaluation =="positive")
  59.             {
  60.                 totalPrice += totalPrice * 0.25;
  61.             }
  62.             else if (evaluation=="negative")
  63.             {
  64.                 totalPrice -= totalPrice * 0.10;
  65.             }
  66.             Console.WriteLine($"{totalPrice:f2}");
  67.  
  68.            
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment