Advertisement
DidiMilikina

03. On Time for the Exam

May 5th, 2017
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace _03.On_Time_for_the_Exam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             var hoursExam = int.Parse(Console.ReadLine());
  14.             var minutesExam = int.Parse(Console.ReadLine());
  15.             var hoursArrival = int.Parse(Console.ReadLine());
  16.             var minutesArrival = int.Parse(Console.ReadLine());
  17.  
  18.             var examTime = hoursExam * 60 + minutesExam;
  19.             var studentTime = hoursArrival * 60 + minutesArrival;
  20.             var minutesDifference = studentTime - examTime;
  21.  
  22.             if (minutesDifference < -30)
  23.             {
  24.                 Console.WriteLine("Early");
  25.             }
  26.             else if (minutesDifference <= 0)
  27.             {
  28.                 Console.WriteLine("On time");
  29.             }
  30.             else
  31.             {
  32.                 Console.WriteLine("Late");
  33.             }
  34.  
  35.             if (minutesDifference != 0)
  36.             {
  37.                 var hours = Math.Abs(minutesDifference / 60);
  38.                 var minutes = Math.Abs(minutesDifference % 60);
  39.                 if (minutesDifference < 0)
  40.                 {
  41.                     if (hours != 0)
  42.                     {
  43.                         if (minutes < 10)
  44.                         {
  45.                             Console.WriteLine($"{hours}:0{minutes} hours before the start");
  46.                         }
  47.                         else
  48.                         {
  49.                             Console.WriteLine($"{hours}:{minutes} hours before the start");
  50.                         }
  51.                      
  52.                     }
  53.                     else
  54.                     {
  55.                         Console.WriteLine($"{minutes} minutes before the start");
  56.                     }
  57.                 }
  58.                 else
  59.                 {
  60.                     if (hours != 0)
  61.                     {
  62.                         if (minutes < 10)
  63.                         {
  64.                             Console.WriteLine($"{hours}:0{minutes} hours after the start");
  65.                         }
  66.                         else
  67.                         {
  68.                             Console.WriteLine($"{hours}:{minutes} hours after the start");
  69.                         }
  70.  
  71.                     }
  72.                     else
  73.                     {
  74.                         Console.WriteLine($"{minutes} minutes after the start");
  75.                     }
  76.                 }
  77.             }
  78.         }
  79.     }
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement