Advertisement
bacco

Theatre Promotion

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