Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class BeerTime
- {
- static void Main()
- {
- /*
- A beer time is after 1:00 PM and before 3:00 AM. Write a program that enters a time in format “hh:mm tt” (an hour in range [01...12], a minute in range [00…59] and AM / PM designator) and prints “beer time” or “non-beer time” according to the definition above or “invalid time” if the time cannot be parsed. Note that you may need to learn how to parse dates and times. E
- */
- DateTime startBeerTime = DateTime.Parse("1:00 PM");
- DateTime endBeerTime = DateTime.Parse("3:00 AM");
- int startBeerHour = startBeerTime.Hour;
- int endBeerHour = endBeerTime.Hour;
- int beerTime = time.Hour;
- if ((beerTime >=startBeerHour) && (beerTime < (endBeerHour+14)))
- {
- Console.WriteLine("beer time");
- }
- else
- {
- Console.WriteLine("non-beer time");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement