Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace ConsoleApplication1
- {
- class Program
- {
- static void Main()
- {
- int examHour = int.Parse(Console.ReadLine());
- int examMinute = int.Parse(Console.ReadLine());
- int arriveHour = int.Parse(Console.ReadLine());
- int arriveMinute = int.Parse(Console.ReadLine());
- int examTime = examHour * 60 + examMinute;
- int arriveTime = arriveHour * 60 + arriveMinute;
- int timeDiff = examTime - arriveTime;
- string result = string.Empty;
- if (timeDiff == 0)
- {
- result = "On time";
- }
- else if (timeDiff >= 1 && timeDiff <= 30)
- {
- result = $"On time\r\n{timeDiff} minutes before the start";
- }
- else if (timeDiff > 30 && timeDiff < 60)
- {
- result = $"Early\r\n{timeDiff} minutes before the start";
- }
- else if (timeDiff >= 60)
- {
- int hour = timeDiff / 60;
- int minute = timeDiff % 60;
- result = $"Early\r\n{hour}:{minute:d2} hours before the start";
- }
- else if (timeDiff <= -1 && timeDiff >= -59)
- {
- result = $"Late\r\n{Math.Abs(timeDiff)} minutes after the start";
- }
- else if (timeDiff <= -60)
- {
- int hour = Math.Abs(timeDiff / 60);
- int minute = Math.Abs(timeDiff % 60);
- result = $"Late\r\n{hour}:{minute:d2} hours after the start";
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement