Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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:
- using System;
- namespace _06._Theatre_Promotion
- {
- class TheatrePromotion
- {
- static void Main(string[] args)
- {
- string typeOfDay = Console.ReadLine().ToLower();
- int age = int.Parse(Console.ReadLine());
- double price = 0;
- if (typeOfDay == "weekday")
- {
- if ((age >= 0 && age <= 18) || (age > 64 && age <= 122))
- {
- price = 12;
- }
- else if (age > 18 && age <= 64)
- {
- price = 18;
- }
- }
- else if (typeOfDay == "weekend")
- {
- if ((age >= 0 && age <= 18) || (age > 64 && age <= 122))
- {
- price = 15;
- }
- else if (age > 18 && age <= 64)
- {
- price = 20;
- }
- }
- else if (typeOfDay == "holiday")
- {
- if (age >= 0 && age <= 18)
- {
- price = 5;
- }
- else if (age > 18 && age <= 64)
- {
- price = 12;
- }
- else if ((age > 64 && age <= 122))
- {
- price = 10;
- }
- }
- else
- {
- Console.WriteLine("Error!");
- }
- if (price != 0)
- {
- Console.WriteLine(price + "$");
- }
- else
- {
- Console.WriteLine("Error!");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment