MiroslavKisov

On_Time_For_The_Exam

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