Advertisement
fbinnzhivko

Untitled

Jan 16th, 2017
243
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.28 KB | None | 0 0
  1. using System;
  2.  
  3. class Program
  4. {
  5.     static void Main()
  6.     {
  7.         var startExamHour = int.Parse(Console.ReadLine());
  8.         var startExamMinutes = int.Parse(Console.ReadLine());
  9.         var comeHour = int.Parse(Console.ReadLine());
  10.         var comeMinutes = int.Parse(Console.ReadLine());
  11.  
  12.         var examTime = startExamHour * 60 + startExamMinutes;
  13.         var comeTime = comeHour * 60 + comeMinutes;
  14.         var minutesDifference = comeTime - examTime;
  15.         var hours = Math.Abs(minutesDifference / 60);
  16.         var minutes = Math.Abs(minutesDifference % 60);
  17.  
  18.         if (minutesDifference < -30) { Console.WriteLine("Early"); }
  19.         else if (minutesDifference < 0) { Console.WriteLine("On time"); }
  20.         else if (minutesDifference == 0) { Console.WriteLine("On time"); }
  21.         else { Console.WriteLine("Late"); }
  22.  
  23.         if (hours > 0)
  24.         {
  25.             if (minutes < 10)
  26.                 Console.Write(hours + ":0" + minutes + " hours");
  27.             else
  28.                 Console.Write(hours + ":" + minutes + " hours");
  29.         }
  30.         else
  31.             Console.Write(minutes + " minutes");
  32.         if (minutesDifference < 0)
  33.             Console.WriteLine(" before the start");
  34.         else
  35.             Console.WriteLine(" after the start");
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement