Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace MatchTicket
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- string category = Console.ReadLine();
- int people = int.Parse(Console.ReadLine());
- if (people <= 4)
- {
- budget *= 0.25;
- }
- else if (people <= 9)
- {
- budget *= 0.4;
- }
- else if (people <= 24)
- {
- budget *= 0.5;
- }
- else if (people < 50)
- {
- budget *= 0.6;
- }
- else
- {
- budget *= 0.75;
- }
- if (category == "VIP")
- {
- budget -= 499.99 * people;
- }
- else
- {
- budget -= 249.99 * people;
- }
- if (budget >= 0)
- {
- Console.WriteLine($"Yes! You have {budget:F2} leva left.");
- }
- else
- {
- Console.WriteLine($"Not enough money! You need {Math.Abs(budget):F2} leva.");
- }
- }
- }
- }
- Решение с тернарен оператор:
- using System;
- namespace MatchTicket
- {
- class Program
- {
- static void Main(string[] args)
- {
- double budget = double.Parse(Console.ReadLine());
- string category = Console.ReadLine();
- int people = int.Parse(Console.ReadLine());
- budget *=
- people <= 4 ? 0.25 :
- people <= 9 ? 0.4 :
- people <= 24 ? 0.5 :
- people < 50 ? 0.6 : 0.75;
- budget -= (category == "VIP" ? 499.99 : 249.99) * people;
- Console.WriteLine(budget >= 0 ? $"Yes! You have {budget:F2} leva left."
- : $"Not enough money! You need {Math.Abs(budget):F2} leva.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement