Advertisement
ElviraPetkova

OnTimeForTheExam

Nov 16th, 2018
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.51 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 OnTimeForTheExam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int hoursExam = int.Parse(Console.ReadLine());
  14.             int minutesExam = int.Parse(Console.ReadLine());
  15.             int hoursComing = int.Parse(Console.ReadLine());
  16.             int minutesComing = int.Parse(Console.ReadLine());
  17.  
  18.             int minutesFromHoursExam = hoursExam * 60;
  19.             int timeExamInMinutes = minutesFromHoursExam + minutesExam;
  20.             int minutesFromHoursGoming = hoursComing * 60;
  21.             int timeGomingInMinutes = minutesFromHoursGoming + minutesComing;
  22.  
  23.             if (timeGomingInMinutes > timeExamInMinutes)
  24.             {
  25.                 double timeLate = timeGomingInMinutes - timeExamInMinutes;
  26.                 if (timeLate < 60)
  27.                 {
  28.                     Console.WriteLine("Late");
  29.                     Console.WriteLine("{0} minutes after the start", timeLate);
  30.                 }
  31.                 else if (timeLate >= 60)
  32.                 {
  33.                     double hoursLate = Math.Floor (timeLate / 60);
  34.                     double minutesLate = timeLate % 60;
  35.                     Console.WriteLine("Late");
  36.                     Console.WriteLine("{0}:{1:00} hours after the start", hoursLate, minutesLate);
  37.                 }
  38.             }
  39.             else if ((timeGomingInMinutes + 30 >= timeExamInMinutes) && (timeGomingInMinutes <= (timeExamInMinutes + 30)))
  40.             {
  41.                 double timeOnTime = timeExamInMinutes - timeGomingInMinutes;
  42.                 Console.WriteLine("On time");
  43.                 Console.WriteLine("{0} minutes before the start", timeOnTime);
  44.             }
  45.             else if (timeGomingInMinutes < timeExamInMinutes)
  46.             {
  47.                 var timeEarly = timeExamInMinutes - timeGomingInMinutes;
  48.                 if (timeEarly < 60)
  49.                 {
  50.                     Console.WriteLine("Early");
  51.                     Console.WriteLine("{0} minutes before the start", timeEarly);
  52.                 }
  53.                 else if (timeEarly >= 60)
  54.                 {
  55.                     var hoursEarly = timeEarly / 60;
  56.                     var minutesEarly = timeEarly % 60;
  57.                     Console.WriteLine("Early");
  58.                     Console.WriteLine("{0} {1:00} hours before the start", hoursEarly, minutesEarly);
  59.                 }
  60.             }
  61.  
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement