M0Hk

SkiTrip

Feb 25th, 2020
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.86 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _10.SkiTrip
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             string typeOfRoom = Console.ReadLine();
  11.             string feedback = Console.ReadLine();
  12.  
  13.             double priceForOneNight = 0;
  14.             double discount = 0;
  15.  
  16.             if(typeOfRoom == "room for one person")
  17.             {
  18.                 priceForOneNight = 18;
  19.             }
  20.             else if(typeOfRoom == "apartment")
  21.             {
  22.                 priceForOneNight = 25;
  23.  
  24.                 if (days < 10)
  25.                 {
  26.                     discount = 0.30;
  27.                 }
  28.                 else if (days >= 10 && days <= 15)
  29.                 {
  30.                     discount = 0.35;
  31.                 }
  32.                 else if (days > 15)
  33.                 {
  34.                     discount = 0.50;
  35.                 }
  36.             }
  37.             else if(typeOfRoom == "president apartment")
  38.             {
  39.                 priceForOneNight = 35;
  40.  
  41.                 if (days < 10)
  42.                 {
  43.                     discount = 0.10;
  44.                 }
  45.                 else if (days >= 10 && days <= 15)
  46.                 {
  47.                     discount = 0.15;
  48.                 }
  49.                 else if (days > 15)
  50.                 {
  51.                     discount = 0.20;
  52.                 }
  53.             }
  54.             int nights = days - 1;
  55.             double totalPrice = nights * priceForOneNight;
  56.  
  57.             totalPrice -= totalPrice * discount;
  58.  
  59.             if (feedback == "positive")
  60.             {
  61.                 totalPrice += totalPrice * 0.25;
  62.             }
  63.             else if (feedback == "negative")
  64.             {
  65.                 totalPrice -= totalPrice * 0.10;
  66.             }
  67.  
  68.             Console.WriteLine($"{totalPrice:F2}");
  69.         }  
  70.  
  71.     }
  72. }
Add Comment
Please, Sign In to add comment