Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Globalization;
- namespace Problem10
- {
- class Program
- {
- static void Main(string[] args)
- {
- string dateString = Console.ReadLine();
- string format = "h:mm tt";
- DateTime dateTime;
- if (DateTime.TryParseExact(dateString, format, CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
- {
- string partOfDay = dateTime.ToString("tt", CultureInfo.InvariantCulture);
- if ((partOfDay == "PM" && dateTime.Hour > 1) || (partOfDay == "AM" && dateTime.Hour<3))
- {
- Console.WriteLine("beer time");
- }
- else
- {
- Console.WriteLine("non-beer time");
- }
- }
- else
- {
- Console.WriteLine("invalid time");
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement