Advertisement
desito07

On_Time_For_Exam

Sep 18th, 2023
3,207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.95 KB | None | 0 0
  1. namespace _08._On_Time_For_Exam
  2. {
  3.     internal class Program
  4.     {
  5.         static void Main(string[] args)
  6.         {
  7.             int hourExamStart = int.Parse(Console.ReadLine());
  8.             int minExamStart = int.Parse(Console.ReadLine());
  9.             int hourArival = int.Parse(Console.ReadLine());
  10.             int minArival = int.Parse(Console.ReadLine());
  11.  
  12.             int minExamStartTotal = hourExamStart * 60 + minExamStart;
  13.             int minArivalTotal = hourArival * 60 + minArival;
  14.  
  15.             if (minArivalTotal > minExamStartTotal)
  16.             {
  17.                 Console.WriteLine("Late");
  18.                 int minDifference = minArivalTotal - minExamStartTotal;
  19.                 if (minDifference < 60)
  20.                 {
  21.                     Console.WriteLine($"{minDifference} minutes after the start");
  22.                 }
  23.                 else
  24.                 {
  25.                     int hours = minDifference / 60;
  26.                     int min = minDifference % 60;
  27.                     Console.WriteLine($"{hours}:{min:d2} hours after the start");
  28.                 }
  29.             }
  30.             else if (minArivalTotal < minExamStartTotal - 30)
  31.             {
  32.                 Console.WriteLine("Early");
  33.                 int minDifference = minExamStartTotal - minArivalTotal;
  34.                 if (minDifference < 60)
  35.                 {
  36.                     Console.WriteLine($"{minDifference} minutes before the start");
  37.                 }
  38.                 else
  39.                 {
  40.                     int hours = minDifference / 60;
  41.                     int min = minDifference % 60;
  42.                     Console.WriteLine($"{hours}:{min:d2} hours before the start");
  43.                 }
  44.             }
  45.             else
  46.             {
  47.                 Console.WriteLine("On time");
  48.                 int minDiff = minExamStartTotal - minArivalTotal;
  49.                 Console.WriteLine($"{minDiff} minutes before the start");
  50.             }
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement