Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- class CheckTime
- {
- static void Main()
- {
- Console.WriteLine("What time is now?");
- Console.Write("Whrite hours: ");
- int hours = int.Parse(Console.ReadLine());
- Console.WriteLine("Write minutes: ");
- int minutes = int.Parse(Console.ReadLine());
- bool isValidTime = CheckValidateHours(hours) && CheckValidateMinutes(minutes);
- if (isValidTime)
- {
- Console.WriteLine("The Time is {0}:{1} now", hours, minutes);
- }
- else
- {
- Console.WriteLine("Incorect Time!");
- }
- }
- private static bool CheckValidateMinutes(int minutes)
- {
- return minutes >= 0 && minutes <= 59;
- }
- private static bool CheckValidateHours(int hours)
- {
- bool result = hours >= 0 && hours <= 23;
- return result;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment