Advertisement
BbJLeB

Ski Holiday2

Sep 15th, 2023
584
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.44 KB | None | 0 0
  1. namespace ТО9
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main()
  6.         {
  7.             // Read input
  8.             int daysToStay = int.Parse(Console.ReadLine());
  9.             string roomType = Console.ReadLine();
  10.             string assessment = Console.ReadLine();
  11.  
  12.             // Define room prices
  13.             double roomForOnePersonPrice = 118.00;
  14.             double apartmentPrice = 155.00;
  15.             double presidentApartmentPrice = 235.00;
  16.  
  17.             // Calculate the number of nights (for discounts)
  18.             int nights = daysToStay - 1;
  19.  
  20.             // Calculate the initial cost based on room type and nights
  21.             double initialCost = 0.0;
  22.  
  23.             switch (roomType)
  24.             {
  25.                 case "room for one person":
  26.                     initialCost = roomForOnePersonPrice * nights;
  27.                     break;
  28.                 case "apartment":
  29.                     initialCost = apartmentPrice * nights;
  30.                     if (nights < 10)
  31.                     {
  32.                         initialCost *= 0.70; // 30% discount
  33.                     }
  34.                     else if (nights <= 15)
  35.                     {
  36.                         initialCost *= 0.65; // 35% discount
  37.                     }
  38.                     else
  39.                     {
  40.                         initialCost *= 0.50; // 50% discount
  41.                     }
  42.                     break;
  43.                 case "president apartment":
  44.                     initialCost = presidentApartmentPrice * nights;
  45.                     if (nights < 10)
  46.                     {
  47.                         initialCost *= 0.90; // 10% discount
  48.                     }
  49.                     else if (nights <= 15)
  50.                     {
  51.                         initialCost *= 0.85; // 15% discount
  52.                     }
  53.                     else
  54.                     {
  55.                         initialCost *= 0.80; // 20% discount
  56.                     }
  57.                     break;
  58.             }
  59.  
  60.             // Calculate the final cost based on assessment
  61.             if (assessment == "positive")
  62.             {
  63.                 initialCost *= 1.25; // 25% positive assessment bonus
  64.             }
  65.             else if (assessment == "negative")
  66.             {
  67.                 initialCost *= 0.90; // 10% negative assessment deduction
  68.             }
  69.  
  70.             // Print the final cost
  71.             Console.WriteLine($"{initialCost:F2}");
  72.         }
  73.     }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement