Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace WorkingHours
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hour = int.Parse(Console.ReadLine());
- string day = Console.ReadLine();
- if (hour >= 10 && hour <= 18)
- {
- switch (day)
- {
- case "Monday":
- case "Tuesday":
- case "Wednesday":
- case "Thursday":
- case "Friday":
- case "Saturday":
- Console.WriteLine("open");
- break;
- default:
- Console.WriteLine("closed");
- break;
- }
- }
- else
- {
- Console.WriteLine("closed");
- }
- }
- }
- }
- РЕШЕНИЕ С IF-ELSE:
- using System;
- namespace WorkingHours
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hour = int.Parse(Console.ReadLine());
- string day = Console.ReadLine();
- if (hour >= 10 && hour <= 18 && (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday" || day == "Saturday"))
- {
- Console.WriteLine("open");
- }
- else
- {
- Console.WriteLine("closed");
- }
- }
- }
- }
- РЕШЕНИЕ С ТЕРНАРЕН ОПЕРАТОР:
- using System;
- namespace WorkingHours
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hour = int.Parse(Console.ReadLine());
- string day = Console.ReadLine();
- Console.WriteLine(hour >= 10 && hour <= 18 && (day == "Monday" || day == "Tuesday" || day == "Wednesday" || day == "Thursday" || day == "Friday" || day == "Saturday") ? "open" : "closed");
- }
- }
- }
Add Comment
Please, Sign In to add comment