VelizarAvramov

06. Theatre Promotion

Nov 6th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.76 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06._Theatre_Promotion
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             string day = Console.ReadLine();
  10.             int age = int.Parse(Console.ReadLine());
  11.  
  12.             int price = 0;
  13.  
  14.             if (0 > age || age > 122)
  15.             {
  16.                 Console.WriteLine("Error!");
  17.                 return;
  18.             }
  19.  
  20.             switch (day)
  21.             {
  22.                 case "Weekday":
  23.                     if ((0<= age && age <= 18) ||(64 < age && age <= 122))
  24.                     {
  25.                         price += 12;
  26.                     }
  27.                     else if (18 < age && age <= 64)
  28.                     {
  29.                         price += 18;
  30.                     }
  31.                     break;
  32.                 case "Weekend":
  33.                     if ((0 <= age && age <= 18) || (64 < age && age <= 122))
  34.                     {
  35.                         price += 15;
  36.                     }
  37.                     else if (18 < age && age <= 64)
  38.                     {
  39.                         price += 20;
  40.                     }
  41.                     break;
  42.                 case "Holiday":
  43.                     if (0 <= age && age <= 18)
  44.                     {
  45.                         price += 5;
  46.                     }
  47.                     else if (18 < age && age <= 64)
  48.                     {
  49.                         price += 12;
  50.                     }
  51.                     else if (64 < age && age <= 122)
  52.                     {
  53.                         price += 10;
  54.                     }
  55.                     break;
  56.  
  57.                 default: Console.WriteLine("Error!");
  58.                     break;
  59.             }
  60.  
  61.             Console.WriteLine($"{price}$");
  62.         }
  63.     }
  64. }
Add Comment
Please, Sign In to add comment