Advertisement
frxbg

Untitled

Apr 2nd, 2018
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OnTimeForExam
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int hourOfExam = int.Parse(Console.ReadLine());
  10.             int minutesOfExam = int.Parse(Console.ReadLine());
  11.             int hourOfArrival = int.Parse(Console.ReadLine());
  12.             int minutesOfArrival = int.Parse(Console.ReadLine());
  13.  
  14.             int timeOfExam = (hourOfExam * 60) + minutesOfExam;
  15.             int timeOfArrival = (hourOfArrival * 60) + minutesOfArrival;
  16.  
  17.             if (timeOfArrival < (timeOfExam - 30))
  18.             {
  19.                 Console.WriteLine("Early");
  20.                 if (timeOfExam >= timeOfArrival + 60)
  21.                 {
  22.                     Console.WriteLine("{0}:{1:D2} hours before the start", ((timeOfExam - timeOfArrival) / 60), ((timeOfExam - timeOfArrival) % 60));
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine("{0:D2} minutes before the start", (timeOfExam - timeOfArrival));
  27.                 }
  28.             }
  29.             else if (timeOfArrival >= timeOfExam - 30 && timeOfArrival <= timeOfExam)
  30.             {
  31.                 Console.WriteLine("On time");
  32.                 if ((timeOfExam - timeOfArrival) >= 1)
  33.                 {
  34.                     Console.WriteLine("{0} minutes before the start", (timeOfExam - timeOfArrival));
  35.                 }
  36.             }
  37.             else if (timeOfArrival > timeOfExam)
  38.             {
  39.                 Console.WriteLine("Late");
  40.                 if (timeOfArrival >= timeOfExam + 60)
  41.                 {
  42.                     Console.WriteLine("{0}:{1:D2} hours after the start", ((timeOfArrival - timeOfExam) / 60), ((timeOfArrival - timeOfExam) % 60));
  43.                 }
  44.                 else
  45.                 {
  46.                     Console.WriteLine("{0:D2} minutes after the start", (timeOfArrival - timeOfExam));
  47.                 }
  48.             }
  49.         }
  50.     }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement