VelizarAvramov

06. Theatre Promotion

Jul 17th, 2018
128
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. A theatre is doing a ticket sale, but they need a program to calculate the price of a single ticket. If the given age does not fit one of the categories, you should print "Error!".  You can see the prices in the table below:
  2. using System;
  3.  
  4. namespace _06._Theatre_Promotion
  5. {
  6.     class TheatrePromotion
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             string typeOfDay = Console.ReadLine().ToLower();
  11.             int age = int.Parse(Console.ReadLine());
  12.             double price = 0;
  13.  
  14.             if (typeOfDay == "weekday")
  15.             {
  16.                 if ((age >= 0 && age <= 18) || (age > 64 && age <= 122))
  17.                 {
  18.                     price = 12;
  19.                 }
  20.                 else if (age > 18 && age <= 64)
  21.                 {
  22.                     price = 18;
  23.                 }
  24.             }
  25.             else if (typeOfDay == "weekend")
  26.             {
  27.                 if ((age >= 0 && age <= 18) || (age > 64 && age <= 122))
  28.                 {
  29.                     price = 15;
  30.                 }
  31.                 else if (age > 18 && age <= 64)
  32.                 {
  33.                     price = 20;
  34.                 }
  35.             }
  36.             else if (typeOfDay == "holiday")
  37.             {
  38.                 if (age >= 0 && age <= 18)
  39.                 {
  40.                     price = 5;
  41.                 }
  42.                 else if (age > 18 && age <= 64)
  43.                 {
  44.                     price = 12;
  45.                 }
  46.                 else if ((age > 64 && age <= 122))
  47.                 {
  48.                     price = 10;
  49.                 }
  50.             }
  51.             else
  52.             {
  53.                 Console.WriteLine("Error!");
  54.             }
  55.             if (price != 0)
  56.             {
  57.                 Console.WriteLine(price + "$");
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine("Error!");
  62.             }
  63.         }
  64.     }
  65. }
Advertisement
Add Comment
Please, Sign In to add comment