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 @byte
- {
- class Program
- {
- static void Main(string[] args)
- {
- //• Първият ред съдържа час на изпита – цяло число от 0 до 23.
- //• Вторият ред съдържа минута на изпита – цяло число от 0 до 59.
- //• Третият ред съдържа час на пристигане – цяло число от 0 до 23.
- //• Четвъртият ред съдържа минута на пристигане – цяло число от 0 до 59.
- int hourOfExam = int.Parse(Console.ReadLine());
- int minuteOfExam = int.Parse(Console.ReadLine());
- int hourOfArrival = int.Parse(Console.ReadLine());
- int minuteOfArrival = int.Parse(Console.ReadLine());
- int examTotalMinutes = hourOfExam * 60 + minuteOfExam;
- int arrivalTotalMinutes = hourOfArrival * 60 + minuteOfArrival;
- int totalMinuteDifference = arrivalTotalMinutes - examTotalMinutes;
- int absTotalMinuteDiff = Math.Abs(totalMinuteDifference);
- int hour = absTotalMinuteDiff / 60;
- int minute = absTotalMinuteDiff % 60;
- string result = "";
- if (examTotalMinutes == arrivalTotalMinutes)
- {
- result = "On time";
- }
- else if (totalMinuteDifference >= -30 && totalMinuteDifference <= -1)
- {
- result = $"On time{Environment.NewLine}{absTotalMinuteDiff} minutes before the start";
- }
- else if (totalMinuteDifference >= -59 && totalMinuteDifference <= -31)
- {
- result = $"Early{Environment.NewLine}{absTotalMinuteDiff} minutes before the start";
- }
- else if (totalMinuteDifference <= -60)
- {
- result = $"Early{Environment.NewLine}{hour}:{minute:d2} hours before the start";
- }
- else if (totalMinuteDifference >= 1 && totalMinuteDifference <= 59)
- {
- result = $"Late{Environment.NewLine}{absTotalMinuteDiff} minutes after the start";
- }
- else if (totalMinuteDifference >= 60)
- {
- result = $"Late{Environment.NewLine}{hour}:{minute:d2} hours after the start";
- }
- Console.WriteLine(result);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement