Advertisement
remote87

Beer Time

Sep 2nd, 2015
545
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.11 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading;
  6. using System.Globalization;
  7.  
  8. namespace _10.BeerTime
  9. {
  10.     class BeerTime
  11.     {
  12.         static void Main()
  13.         {
  14.             Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture;
  15.             Console.Write("Enter a time in format (hh:mm tt): ");
  16.             string format = "hh:mm tt";
  17.             string wishTime = Console.ReadLine();
  18.             string startTime = "01:00 PM";
  19.             string endTime = "03:00 AM";
  20.             DateTime wish = DateTime.ParseExact(wishTime, format, CultureInfo.InvariantCulture);
  21.             DateTime start = DateTime.ParseExact(startTime, format, CultureInfo.InvariantCulture);
  22.             DateTime end = DateTime.ParseExact(endTime, format, CultureInfo.InvariantCulture);
  23.             if ((wish > start) && (wish < end))
  24.             {
  25.                 Console.WriteLine("YEEEEES! BEER TIME!!!");
  26.             }
  27.             else
  28.             {
  29.                 Console.WriteLine("No beer for you! Keep studying!!!");
  30.             }
  31.         }
  32.     }
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement