Advertisement
VickyFilly

OnTimeForExam

Feb 11th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.14 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _1OnTimeforExam
  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 ArriveMin = int.Parse(Console.ReadLine());
  13.  
  14.             string early = "Early";
  15.             string ontime = "On time";
  16.             string late = "Late";
  17.  
  18.             var examtime = (ExamHour * 60) + ExamMin;
  19.             var arrivetime = (ArriveHour * 60) + ArriveMin;
  20.  
  21.             var totaldifference = arrivetime - examtime;
  22.  
  23.             if (totaldifference > 0)
  24.             {
  25.                 if (totaldifference <= 59)
  26.                 {
  27.                     Console.WriteLine(late);
  28.                     Console.WriteLine("{0} minutes after the start", totaldifference);
  29.                 }
  30.                 else if (totaldifference >= 60)
  31.                 {
  32.                     Console.WriteLine(late);
  33.                     Console.WriteLine("{0}:{1:00} hours after the start", (arrivetime - examtime) / 60, (arrivetime - examtime) % 60);
  34.                 }
  35.             }
  36.  
  37.             if (totaldifference < 0)
  38.             {
  39.                 if (Math.Abs(totaldifference) <= 30)
  40.                 {
  41.                     Console.WriteLine(ontime);
  42.                     Console.WriteLine("{0} minutes before the start", Math.Abs(totaldifference));
  43.                 }
  44.                 else if (Math.Abs(totaldifference) > 30 && Math.Abs(totaldifference) <= 59)
  45.                 {
  46.                     Console.WriteLine(early);
  47.                     Console.WriteLine("{0} minutes before the start", Math.Abs(totaldifference));
  48.                 }
  49.                 else if (Math.Abs(totaldifference) >= 60)
  50.                 {
  51.                     Console.WriteLine(early);
  52.                     Console.WriteLine("{0}:{1:00} hours before the start", (examtime - arrivetime) / 60, (examtime - arrivetime) % 60);
  53.                 }
  54.             }
  55.             else if (totaldifference == 0)
  56.             { Console.WriteLine(ontime); }
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement