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 Practice
- {
- class Program
- {
- static void Main(string[] args)
- {
- int hourExam = int.Parse(Console.ReadLine());
- int minuteExam = int.Parse(Console.ReadLine());
- int hourArrive = int.Parse(Console.ReadLine());
- int minuteArrive = int.Parse(Console.ReadLine());
- if (hourExam==0)
- {
- hourExam = 24;
- }
- if (hourArrive==0)
- {
- hourArrive = 24;
- }
- TimeSpan exam = TimeSpan.FromHours(hourExam) + TimeSpan.FromMinutes(minuteExam);
- TimeSpan arrive = TimeSpan.FromHours(hourArrive) + TimeSpan.FromMinutes(minuteArrive);
- TimeSpan result = TimeSpan.MinValue;
- int hours = 0;
- int minutes = 0;
- TimeSpan zero = TimeSpan.Zero;
- int thirthyForMinutes = 30;
- int oneForHour = 1;
- TimeSpan thirthy = TimeSpan.FromMinutes(thirthyForMinutes);
- TimeSpan oneHour = TimeSpan.FromHours(oneForHour);
- if (exam >= arrive)
- {
- result = exam - arrive;
- hours = result.Hours;
- minutes = result.Minutes;
- if (exam == arrive)
- {
- Console.WriteLine("On time");
- }
- else if (result<=thirthy)
- {
- Console.WriteLine("On time");
- Console.WriteLine("{0} minutes before the start",minutes);
- }
- else if (result>= thirthy && result < oneHour)
- {
- Console.WriteLine("Early");
- Console.WriteLine("{0} minutes before the start", minutes);
- }
- else if (result>= oneHour)
- {
- Console.WriteLine("Early");
- Console.WriteLine("{0}:{1:d2} hours before the start",hours,minutes);
- }
- }
- else
- {
- result = arrive - exam;
- hours = result.Hours;
- minutes = result.Minutes;
- if (result<oneHour)
- {
- Console.WriteLine("Late");
- Console.WriteLine("{0} minutes after the start", minutes);
- }
- if (result>oneHour)
- {
- Console.WriteLine("Late");
- Console.WriteLine("{0}:{1:d2} hours after the start", hours, minutes);
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement