Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- static void Main()
- {
- string time = Console.ReadLine();
- string[] split = time.Split(':', ' ');
- int hours = int.Parse(split[0]);
- int minutes = int.Parse(split[1]);
- string designator = split[2].ToLower();
- if (hours >= 1 && hours <= 12 && minutes >= 0 && minutes < 60 &&
- (designator == "pm" || designator == "am"))
- {
- if ((designator == "am" && hours <= 2) || (designator == "pm" && hours >= 1))
- {
- Console.WriteLine("beer time");
- }
- else
- {
- Console.WriteLine("non-beer time");
- }
- }
- else
- {
- Console.WriteLine("not correct input");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment