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 ArriveOnTime
- {
- class ArriveOnTime
- {
- static void Main(string[] args)
- {
- var examHour = int.Parse(Console.ReadLine());
- var examMinutes = int.Parse(Console.ReadLine());
- var hourArrive = int.Parse(Console.ReadLine());
- var minArrive = int.Parse(Console.ReadLine());
- string late = "Late";
- string onTime = "On time";
- string early = "Early";
- int examTime = (60 * examHour) + examMinutes;
- int arriveTime = (60 * hourArrive) + minArrive;
- int totalMinutesArrival = arriveTime - examTime;
- string studentArrival = string.Empty;
- if (totalMinutesArrival < -30)
- {
- studentArrival = early;
- }
- else if (totalMinutesArrival <= 30)
- {
- studentArrival = onTime;
- }
- else
- {
- studentArrival = late;
- }
- string result = string.Empty;
- if (totalMinutesArrival != 0)
- {
- int hoursDifference = Math.Abs(totalMinutesArrival / 60);
- int minutesDifference = Math.Abs(totalMinutesArrival % 60);
- if (hoursDifference > 0)
- {
- result = string.Format("{0}:{1:00} hours", hoursDifference, minutesDifference);
- }
- else
- {
- result = minutesDifference + " minutes";
- }
- if (totalMinutesArrival < 0)
- {
- result += " before the start";
- }
- else
- {
- result += " after the start";
- }
- }
- Console.WriteLine(studentArrival);
- if (!string.IsNullOrEmpty(result))
- {
- Console.WriteLine(result);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement