Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace TransportPrice
- {
- class Program
- {
- static void Main(string[] args)
- {
- int km = int.Parse(Console.ReadLine());
- string time = Console.ReadLine();
- double price = 0;
- if (km < 20)
- {
- if (time == "day")
- {
- price = km * 0.79 + 0.7;
- }
- else
- {
- price = km * 0.9 + 0.7;
- }
- }
- else if (km >= 100)
- {
- price = km * 0.06;
- }
- else
- {
- price = km * 0.09;
- }
- Console.WriteLine($"{price:F2}");
- }
- }
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- using System;
- namespace TransportPrice
- {
- class Program
- {
- static void Main(string[] args)
- {
- int km = int.Parse(Console.ReadLine());
- string time = Console.ReadLine();
- double price = km < 20 ? km * (time == "day" ? 0.79 : 0.9) + 0.7 : km >= 100 ? km * 0.06 : km * 0.09;
- Console.WriteLine($"{price:F2}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement