anizko

09. On Time for the Exam

Apr 1st, 2019
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.25 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.  
  10.             int hhStart = int.Parse(Console.ReadLine());
  11.             int mmStart = int.Parse(Console.ReadLine());
  12.             int hhCome = int.Parse(Console.ReadLine());
  13.             int mmCome = int.Parse(Console.ReadLine());
  14.  
  15.             int allStart = hhStart * 60 + mmStart;
  16.             int allCome = hhCome * 60 + mmCome;
  17.  
  18.             string LateEarly = string.Empty;
  19.  
  20.             if (allCome <= allStart)
  21.             {
  22.                 if (allStart - 30 > allCome)
  23.                 {
  24.                     LateEarly = "Early";
  25.                    
  26.                 }
  27.                 else
  28.                 {
  29.                     LateEarly = "On time";
  30.                 }
  31.                                            }
  32.             else
  33.             {
  34.                 LateEarly = "Late";
  35.             }
  36.             if (allStart > allCome)
  37.             {
  38.                
  39.             }
  40.             Console.WriteLine($"{LateEarly}");
  41.  
  42.             double mm = Math.Abs((allStart - allCome) % 60);
  43.             double hh = Math.Abs((allStart - allCome) / 60);
  44.  
  45.             if (allCome < allStart)
  46.             {
  47.                 if (hh!=0 && mm >= 0 && mm < 10)
  48.                 {
  49.                     Console.WriteLine($"{hh:f0}:0{mm} hours before the start");
  50.                 }
  51.                 else if(hh != 0)
  52.                 {
  53.                     Console.WriteLine($"{hh:f0}:{mm} hours before the start");
  54.                 }
  55.                 else if (hh==0)
  56.                 {
  57.                     Console.WriteLine($"{mm} minutes before the start");
  58.                 }
  59.             }
  60.             else if (allCome > allStart)
  61.             {
  62.                 if (hh != 0 && mm >= 0 && mm < 10)
  63.                 {
  64.                     Console.WriteLine($"{hh:f0}:0{mm} hours after the start");
  65.                 }
  66.                 else if (hh != 0)
  67.                 {
  68.                     Console.WriteLine($"{hh:f0}:{mm} hours after the start");
  69.                 }
  70.                 else if (hh == 0)
  71.                 {
  72.                     Console.WriteLine($"{mm} minutes after the start");
  73.                 }
  74.             }
  75.  
  76.  
  77.         }
  78.     }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment