Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - Lab (07. Theatre Promotion)

Mar 11th, 2021
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.20 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TheatrePromotion
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             string day = Console.ReadLine();
  14.             int age = int.Parse(Console.ReadLine());
  15.             int price = 0;
  16.  
  17.             if (day == "Weekday")
  18.             {
  19.                 if (age >= 0 && age <= 18)
  20.                 {
  21.                     price = 12;
  22.                 }
  23.                 else if (age > 18 && age <= 64)
  24.                 {
  25.                     price = 18;
  26.                 }
  27.                 else if (age > 64 && age <= 122)
  28.                 {
  29.                     price = 12;
  30.                 }
  31.                 else
  32.                 {
  33.                     Console.WriteLine("Error!");
  34.                     Environment.Exit(0);
  35.                 }
  36.                 Console.WriteLine(price + "$");
  37.             }
  38.             else if (day == "Weekend")
  39.             {
  40.                 if (age >= 0 && age <= 18)
  41.                 {
  42.                     price = 15;
  43.                 }
  44.                 else if (age > 18 && age <= 64)
  45.                 {
  46.                     price = 20;
  47.                 }
  48.                 else if (age > 64 && age <= 122)
  49.                 {
  50.                     price = 15;
  51.                 }
  52.                 else
  53.                 {
  54.                     Console.WriteLine("Error!");
  55.                     Environment.Exit(0);
  56.                 }
  57.                 Console.WriteLine(price + "$");
  58.             }
  59.             else if (day == "Holiday")
  60.             {
  61.                 if (age >= 0 && age <= 18)
  62.                 {
  63.                     price = 5;
  64.                 }
  65.                 else if (age > 18 && age <= 64)
  66.                 {
  67.                     price = 12;
  68.                 }
  69.                 else if (age > 64 && age <= 122)
  70.                 {
  71.                     price = 10;
  72.                 }
  73.                 else
  74.                 {
  75.                     Console.WriteLine("Error!");
  76.                     Environment.Exit(0);
  77.                 }
  78.                 Console.WriteLine(price + "$");
  79.             }
  80.         }
  81.     }
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement