knikolov98

Untitled

Sep 17th, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.61 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 ConsoleApp17
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int examHours = int.Parse(Console.ReadLine());
  14.             int examMinutes = int.Parse(Console.ReadLine());
  15.             int arrivalHours = int.Parse(Console.ReadLine());
  16.             int arrivalMinutes = int.Parse(Console.ReadLine());
  17.             int examTime = (examHours * 60) + examMinutes;
  18.             int arivalTime = (arrivalHours * 60) + arrivalMinutes;
  19.             int timeDifference = examTime - arivalTime;
  20.             int otherdifference = arivalTime - examTime;
  21.             if (timeDifference >= 0 && timeDifference <= 30)
  22.             {
  23.                 if (timeDifference == 0)
  24.                 {
  25.                     Console.WriteLine("On time");
  26.                 }
  27.                 else if (timeDifference > 0 && timeDifference <= 30)
  28.                 {
  29.                     Console.WriteLine("On time");
  30.                     Console.WriteLine("{0} minutes before the start", timeDifference);
  31.                 }
  32.             }
  33.             else if (timeDifference > 30 && timeDifference <= 59)
  34.             {
  35.                 Console.WriteLine("Early");
  36.                 Console.WriteLine("{0} minutes before the start", timeDifference);
  37.             }
  38.             else if (timeDifference > 59)
  39.             {
  40.                 int hours = timeDifference / 60;
  41.                 int min = timeDifference % 60;
  42.                 Console.WriteLine("Early");
  43.                 if (min < 10)
  44.                 {
  45.                     Console.WriteLine("{0}:0{1} hours before the start", hours, min);
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine("{0}:{1} hours before the start", hours, min);
  50.                 }
  51.             }
  52.             else if (otherdifference <= 59)
  53.             {
  54.                 Console.WriteLine("Late");
  55.                 Console.WriteLine("{0} minutes after the start", otherdifference);
  56.             }
  57.             else if (otherdifference > 59)
  58.             {
  59.                 int hours = otherdifference / 60;
  60.                 int min = otherdifference % 60;
  61.                 Console.WriteLine("Late");
  62.                 if (min < 10)
  63.                 {
  64.                     Console.WriteLine("{0}:0{1} hours after the start", hours, min);
  65.                 }
  66.                 else
  67.                 {
  68.                     Console.WriteLine("{0}:{1} hours after the start", hours, min);
  69.                 }
  70.             }
  71.         }
  72.     }
  73. }
Add Comment
Please, Sign In to add comment