Advertisement
ivanov_ivan

OnTimeForExam

Mar 6th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.81 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 OnTimeForExam
  8. {
  9.     class OnTimeForExam
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int startHours = int.Parse(Console.ReadLine());
  14.             int startMinutes = int.Parse(Console.ReadLine());
  15.  
  16.             int hours = int.Parse(Console.ReadLine());
  17.             int minutes = int.Parse(Console.ReadLine());
  18.  
  19.             TimeSpan startExam = new TimeSpan(startHours , startMinutes , 0);
  20.             TimeSpan studentCom = new TimeSpan(hours , minutes , 0);
  21.  
  22.             TimeSpan time = startExam - studentCom;
  23.  
  24.             if(time.TotalMinutes < 0)
  25.             {
  26.                 Console.WriteLine("Late");
  27.             }
  28.             else if(time.Minutes > 30 || time.Hours > 0)
  29.             {
  30.                 Console.WriteLine("Early");
  31.             }
  32.             else
  33.             {
  34.                 Console.WriteLine("On time");
  35.             }
  36.  
  37.             if(time.TotalMinutes != 0)
  38.             {
  39.                 if(time.TotalMinutes <= 59 && time.TotalMinutes > 0)
  40.                 {
  41.                     Console.WriteLine("{0} minutes before the start", time.TotalMinutes);
  42.                 }
  43.                 else if(time.TotalMinutes > 59)
  44.                 {
  45.                     Console.WriteLine("{0:%h}:{0:mm} hours before the start" , time);
  46.                 }
  47.                 else if(time.TotalMinutes < 0 && time.TotalMinutes >= -59)
  48.                 {
  49.                     Console.WriteLine("{0} minutes after the start" ,Math.Abs(time.TotalMinutes));
  50.                 }
  51.                 else
  52.                 {
  53.                     Console.WriteLine("{0:%h}:{0:mm} hours after the start" , time);
  54.                 }
  55.             }
  56.         }
  57.     }
  58. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement