Advertisement
MARINA_GREBENAROVA

On Time

Oct 3rd, 2021
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. using System;
  2.  
  3. namespace On_Time_for_the_Exam
  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 difference = 0;
  15.             int hour = 0;
  16.             int minutes = 0;
  17.  
  18.             examMinutes += examHour * 60;
  19.             arrivalMinutes += arrivalHour * 60;
  20.  
  21.             if (arrivalMinutes > examMinutes)
  22.             {
  23.                 Console.WriteLine("Late");
  24.                 difference = arrivalMinutes - examMinutes;
  25.  
  26.                 if (difference < 60)
  27.                 {
  28.                     Console.WriteLine($"{difference} minutes after the start");
  29.                 }
  30.                 else
  31.                 {
  32.                     hour = difference / 60;
  33.                     minutes = difference % 60;
  34.                     Console.WriteLine($"{hour}:{minutes:d2} hours after the start");
  35.                 }
  36.             }
  37.             else if (arrivalMinutes < examMinutes - 30)
  38.             {
  39.                 Console.WriteLine("Early");
  40.                 difference = examMinutes - arrivalMinutes;
  41.                 if (difference<60)
  42.                 {
  43.                     Console.WriteLine($"{difference} minutes before the start");
  44.                 }
  45.                 else
  46.                 {
  47.                     hour = difference / 60;
  48.                     minutes = difference % 60;
  49.                     Console.WriteLine($"{hour}:{minutes:d2} hours before the start");
  50.                 }
  51.             }
  52.             else
  53.             {
  54.                 Console.WriteLine("On time");
  55.                 difference = examMinutes - arrivalMinutes;
  56.                 Console.WriteLine($"{difference} minutes before the start");
  57.             }
  58.  
  59.  
  60.  
  61.  
  62.         }
  63.     }
  64. }
  65.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement