Advertisement
ramsess

Izpit

Feb 13th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.93 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 Chas_Start = int.Parse(Console.ReadLine());
  10.             int Min_Start = int.Parse(Console.ReadLine());
  11.             int Chas_doshal = int.Parse(Console.ReadLine());
  12.             int Min_doshal = int.Parse(Console.ReadLine());
  13.  
  14.             TimeSpan Vreme_Start = new TimeSpan(Chas_Start, Min_Start, 0);
  15.             TimeSpan Vreme_Doshal = new TimeSpan(Chas_doshal, Min_doshal, 0);
  16.             TimeSpan TS_Result = Vreme_Start - Vreme_Doshal;
  17.  
  18.             string result = "";
  19.             if ((TS_Result.Hours == 0 && TS_Result.Minutes >= -30 && TS_Result.Minutes<=30 && TS_Result.Minutes>=0))
  20.             {
  21.                 result = "On time";
  22.             }
  23.             else if (Vreme_Doshal < Vreme_Start.Add(new TimeSpan(0, -30, 0)))
  24.             {
  25.                 result = "Early";
  26.             }
  27.             else
  28.             {
  29.                 result = "Late";
  30.             }
  31.             if (TS_Result.Hours == 0)
  32.             {
  33.                 if (TS_Result.Ticks > 0)
  34.                 {
  35.                     Console.WriteLine("{0}\n{1} minutes before the start", result, Math.Abs(TS_Result.Minutes));
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine("{0}\n{1} minutes after the start", result, Math.Abs(TS_Result.Minutes));
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 if (TS_Result.Ticks > 0)
  45.                 {
  46.                     Console.WriteLine("{0}\n{1}:{2:00} hours before the start", result, Math.Abs(TS_Result.Hours), Math.Abs(TS_Result.Minutes));
  47.                 }
  48.                 else
  49.                 {
  50.                     Console.WriteLine("{0}\n{1}:{2:00} hours after the start", result, Math.Abs(TS_Result.Hours), Math.Abs(TS_Result.Minutes));
  51.                 }
  52.             }
  53.         }
  54.     }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement