Advertisement
Guest User

Untitled

a guest
Feb 27th, 2020
119
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Exam9
  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 totalExamMinutes = hourOfExam * 60 + minutesOfExam;
  15.             int totalArrivalMinutes = hourOfArrival * 60 + minutesOfArrival;
  16.             int difference = Math.Abs(totalExamMinutes - totalArrivalMinutes);
  17.             int differenceHour = difference / 60;
  18.             int differenceMinutes = difference % 60;
  19.  
  20.             if (totalArrivalMinutes > totalExamMinutes)
  21.             {
  22.                 Console.WriteLine("Late");
  23.                 if (difference < 60)
  24.                 {
  25.                     Console.WriteLine($"{differenceMinutes} minutes after the start");
  26.                 }
  27.                 else if (difference >= 60)
  28.                 {
  29.                     Console.WriteLine($"{differenceHour}:{differenceMinutes:D2} hours after the start");
  30.                 }
  31.             }
  32.             else if (totalArrivalMinutes == totalExamMinutes || difference <= 30)
  33.             {
  34.                 Console.WriteLine("On time");
  35.                 if (difference <= 30)
  36.                 {
  37.                     Console.WriteLine($"{differenceMinutes} minutes before the start");
  38.                 }
  39.             }
  40.             else if (difference > 30)
  41.             {
  42.                 Console.WriteLine("Early");
  43.                 if (difference < 60)
  44.                 {
  45.                     Console.WriteLine($"{differenceMinutes} minutes before the start");
  46.                 }
  47.                 else if (difference >= 60)
  48.                 {
  49.                     Console.WriteLine($"{differenceHour}:{differenceMinutes:D2} hours before the start");
  50.                 }
  51.             }
  52.  
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement