Advertisement
fk4m1913

Untitled

Apr 5th, 2020
252
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.16 KB | None | 0 0
  1. using System;
  2.  
  3. namespace OnTimeForTheExam
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int examHour = int.Parse(Console.ReadLine());
  10.             int examMinutes = int.Parse(Console.ReadLine());
  11.             int arrivalHour = int.Parse(Console.ReadLine());
  12.             int arrivalMinutes = int.Parse(Console.ReadLine());
  13.  
  14.             int timeExam = examHour * 60 + examMinutes;
  15.             int timeArrival = arrivalHour * 60 + arrivalMinutes;
  16.             int difference = 0;
  17.             int hours = 0;
  18.             int minutes = 0;
  19.  
  20.             if (timeArrival > timeExam)
  21.             {
  22.                 Console.WriteLine("Late");
  23.                 difference = timeArrival - timeExam;
  24.                 if (difference < 60)
  25.                 {
  26.                     Console.WriteLine($"{difference} minutes after the start");
  27.                 }
  28.  
  29.                 else if (difference >= 60)
  30.                 {
  31.                     hours = difference / 60;
  32.                     minutes = difference % 60;
  33.                     Console.WriteLine($"{hours}:{minutes:d2} hours after the start");
  34.                 }
  35.  
  36.             }
  37.  
  38.             else if (timeArrival == timeExam || (timeArrival >= timeExam - 30 && timeArrival < timeExam))
  39.             {
  40.                 Console.WriteLine("On time");
  41.                 difference = timeExam - timeArrival;
  42.                 if (difference <= 30)
  43.                 {
  44.                     Console.WriteLine($"{difference} minutes before the start");
  45.                 }
  46.             }
  47.  
  48.             else if (timeArrival < timeExam - 30)
  49.             {
  50.                 Console.WriteLine("Early");
  51.                 difference = timeExam - timeArrival;
  52.                 if (difference < 60)
  53.                 {
  54.                     Console.WriteLine($"{difference} minutes before the start");
  55.                 }
  56.                 else if (difference >= 60)
  57.                 {
  58.                     hours = difference / 60;
  59.                     minutes = difference % 60;
  60.                     Console.WriteLine($"{hours}:{minutes:d2} hours before the start");
  61.                 }
  62.             }
  63.  
  64.         }
  65.     }
  66. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement