Advertisement
YORDAN2347

OnTimeForExam

Nov 20th, 2020
639
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.53 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 examHour = int.Parse(Console.ReadLine());
  10.             int examMin = int.Parse(Console.ReadLine());
  11.             int arriveHour = int.Parse(Console.ReadLine());
  12.             int ariveMin = int.Parse(Console.ReadLine());
  13.  
  14.             int hourDiff = ((examHour * 60) + examMin) - ((arriveHour * 60) + ariveMin);
  15.             string txt = " ";
  16.  
  17.             if(hourDiff < 0 )
  18.             {
  19.                 txt = "Late";
  20.             }
  21.             else if( hourDiff >= 0 && hourDiff <= 30)
  22.             {
  23.                 txt = "On time";
  24.             }
  25.             else
  26.             {
  27.                 txt = "Early";
  28.             }
  29.             Console.WriteLine(txt);
  30.  
  31.             int hours = hourDiff / 60;
  32.             hours *= 60;
  33.  
  34.             if( hourDiff > 0 && hourDiff < 60)
  35.             {
  36.                 Console.WriteLine($"{hourDiff} minutes before the start");
  37.             }
  38.             else if( hourDiff >= 60 )
  39.             {
  40.                 Console.WriteLine($"{hourDiff/60}:{hourDiff-hours} hours before the start");
  41.             }
  42.             else if (hourDiff < 0 && hourDiff > - 60)
  43.             {
  44.                 Console.WriteLine($"{hourDiff*-1} minutes after the start");
  45.             }
  46.             else if (hourDiff <= -60)
  47.             {
  48.                 Console.WriteLine($"{hourDiff / 60 * -1}:{(hourDiff - hours)*-1} hours after the start");
  49.             }
  50.         }
  51.     }
  52. }
  53.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement