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 OnTimeForExam
- {
- class OnTimeForExam
- {
- static void Main(string[] args)
- {
- var startExamHour = int.Parse(Console.ReadLine());
- var startExamMinutes = int.Parse(Console.ReadLine());
- var arrivalExamHour = int.Parse(Console.ReadLine());
- var arrivalExamMinutes = int.Parse(Console.ReadLine());
- var examStartInMinutes = startExamHour * 60 + startExamMinutes;
- var studentArrivalInMinutes = arrivalExamHour * 60 + arrivalExamMinutes;
- var diff = Math.Abs(examStartInMinutes - studentArrivalInMinutes);
- var beforeStart = examStartInMinutes > studentArrivalInMinutes;
- if(beforeStart && diff < 60 && diff > 30)
- {
- Console.WriteLine("Early");
- Console.WriteLine("{0} minutes before the start" , diff);
- }
- else if(beforeStart && diff >= 60)
- {
- Console.WriteLine("Early");
- Console.WriteLine("{0}:{1:0#} hours before the start" , diff / 60 , diff % 60);
- }
- else if(!beforeStart && diff >= 60) // => beforeStart = examStartInMinutes < studentArrivalInMinutes
- {
- Console.WriteLine("Late");
- Console.WriteLine("{0}:{1:0#} hours after the start" , diff / 60 , diff % 60);
- }
- else if(!beforeStart && diff != 0)
- {
- Console.WriteLine("Late");
- Console.WriteLine("{0} minutes after the start" , diff);
- }
- else
- {
- Console.WriteLine("On time");
- if(diff != 0)
- {
- Console.WriteLine("{0} minutes before the start" , diff);
- }
- }
- }
- }
- }
Add Comment
Please, Sign In to add comment