Advertisement
Guest User

On Time for the Exam

a guest
Jul 18th, 2017
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.56 KB | None | 0 0
  1. using System;
  2.  
  3.  
  4. namespace _03.On_Time_for_the_Exam
  5. {
  6.     class Program
  7.     {
  8.         static void Main(string[] args)
  9.         {
  10.             int examHour = int.Parse(Console.ReadLine());
  11.             int examMinute = int.Parse(Console.ReadLine());
  12.             int hourOfArriaval = int.Parse(Console.ReadLine());
  13.             int minuteOfArriaval = int.Parse(Console.ReadLine());
  14.  
  15.  
  16.             int totalExam = examMinute + (examHour * 60);
  17.             int totalArrival = (hourOfArriaval * 60) + minuteOfArriaval;
  18.  
  19.             int result = totalArrival - totalExam; //kind of...
  20.             int onTime = totalExam - totalArrival;  //and early
  21.             int hours = result / 60;
  22.             int min = result % 60;
  23.  
  24.  
  25.             if (totalExam < totalArrival)
  26.             {
  27.                 Console.WriteLine("Late");
  28.                 if (hours == 0)
  29.                 {
  30.                     if (min < 10)
  31.                         Console.WriteLine($"0{min} minutes after the start");
  32.                     else
  33.                         Console.WriteLine($"{min} minutes after the start");
  34.                 }
  35.                 else
  36.                 {
  37.  
  38.                     if (min < 10)
  39.                         Console.WriteLine($"{hours}:0{min} hours after the start");
  40.                     else
  41.                         Console.WriteLine($"{hours}:{min} hours after the start");
  42.                 }
  43.  
  44.  
  45.  
  46.             }
  47.             else if (onTime <= 30)
  48.             {
  49.                 Console.WriteLine("On time");
  50.  
  51.                 min = onTime % 60;
  52.  
  53.                 if (onTime == 0)
  54.                 {
  55.  
  56.                 }
  57.                 else
  58.                     Console.WriteLine($"{min} minutes before the start");
  59.             }
  60.  
  61.             else if (onTime > 30)
  62.             {
  63.                 Console.WriteLine("Early");
  64.                 hours = onTime / 60;
  65.                 min = onTime % 60;
  66.  
  67.                 if (hours == 0)
  68.                 {
  69.  
  70.                     if (min < 10)
  71.                         Console.WriteLine($"0{min} minutes before the start");
  72.                     else
  73.                         Console.WriteLine($"{min} minutes before the start");
  74.                 }
  75.                 else
  76.                 {
  77.                     if (min < 10)
  78.                         Console.WriteLine($"{hours}:0{min} hours before the start");
  79.                     else
  80.                         Console.WriteLine($"{hours}:{min} hours before the start");
  81.                 }
  82.  
  83.  
  84.  
  85.                 ///help :( only 93 of 100 in judge...
  86.             }
  87.  
  88.         }
  89.     }
  90. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement