DyNaMiXx7

Untitled

Oct 19th, 2018
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.17 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main(string[] args)
  6.     {
  7.         string month = Console.ReadLine();
  8.         int totalHours = int.Parse(Console.ReadLine());
  9.         int people = int.Parse(Console.ReadLine());
  10.         string typeOfDay = Console.ReadLine();
  11.  
  12.         double pricePerHour = default(double);
  13.         double totalSum = default(double);
  14.  
  15.         bool arePeopleMoreThanFour = people >= 4;
  16.         bool areHoursMoreThanFive = totalHours >= 5;
  17.  
  18.         if (typeOfDay == "day")
  19.         {
  20.             if (month == "march" || month == "april" || month == "may")
  21.             {
  22.                 pricePerHour += 10.50;  
  23.             }
  24.             else if (month == "june" || month == "july" || month == "august")
  25.             {
  26.                 pricePerHour += 12.60;
  27.             }
  28.             if (arePeopleMoreThanFour)
  29.             {
  30.                 pricePerHour -= (pricePerHour * 0.1);
  31.                 totalSum = pricePerHour * people * totalHours;
  32.             }
  33.             if (areHoursMoreThanFive)
  34.             {
  35.                 pricePerHour -= pricePerHour * 0.5;
  36.                 totalSum = pricePerHour * people * totalHours;
  37.             }
  38.  
  39.             totalSum = pricePerHour * totalHours * people;
  40.         }
  41.         else if (typeOfDay == "night")
  42.         {
  43.             if (month == "march" || month == "april" || month == "may")
  44.             {
  45.                 pricePerHour += 8.40;
  46.             }
  47.             else if (month == "june" || month == "july" || month == "august")
  48.             {
  49.                 pricePerHour += 10.20;
  50.             }
  51.             if (arePeopleMoreThanFour)
  52.             {
  53.                 pricePerHour -= (pricePerHour * 0.1);
  54.                 totalSum = pricePerHour * people * totalHours;
  55.             }
  56.             if (areHoursMoreThanFive)
  57.             {
  58.                 pricePerHour -= pricePerHour * 0.5;
  59.                 totalSum = pricePerHour * people * totalHours;
  60.             }
  61.  
  62.             totalSum = pricePerHour * totalHours * people;
  63.         }
  64.         Console.WriteLine($"Price per person for one hour: {pricePerHour:F2}");
  65.         Console.WriteLine($"Total cost of the visit: {totalSum:F2}");
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment