Advertisement
Niicksana

On Time for the Exam

Dec 3rd, 2017
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 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 On_Time_for_the_Exam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 6 March 2016
  14.             int hourExam = int.Parse(Console.ReadLine());
  15.             int minExam = int.Parse(Console.ReadLine());
  16.             int hourArrival = int.Parse(Console.ReadLine());
  17.             int minArrival = int.Parse(Console.ReadLine());
  18.  
  19.             int timeExam = (hourExam * 60) + minExam;
  20.             int timeArrival = (hourArrival * 60) + minArrival;
  21.  
  22.             int timeInterval = (timeExam - timeArrival);
  23.  
  24.             if (timeInterval >= 0 && timeInterval <= 30)
  25.             {
  26.                 Console.WriteLine("On Time");
  27.                 if (timeInterval == 0)
  28.                 {
  29.                     Console.WriteLine();
  30.                 }
  31.  
  32.                 else
  33.                 {
  34.                     Console.WriteLine("{0} minutes before the start", timeInterval);
  35.                 }
  36.             }
  37.  
  38.             else if (timeInterval > 30)
  39.             {
  40.                 Console.WriteLine("Early");
  41.                 if (timeInterval < 60)
  42.                 {
  43.                     Console.WriteLine("{0} minutes before the start", timeInterval);
  44.                 }
  45.  
  46.                 else
  47.                 {
  48.                     Console.WriteLine("{0}:{1:00} hours before the start", timeInterval / 60, timeInterval - (timeInterval / 60) * 60);
  49.                 }
  50.             }
  51.  
  52.             else
  53.             {
  54.                 Console.WriteLine("late");
  55.                 timeInterval = -timeInterval;
  56.  
  57.                 if (timeInterval < 60)
  58.                 {
  59.                     Console.WriteLine("{0} minutes after the start", timeInterval);
  60.                 }
  61.  
  62.                 else
  63.                 {
  64.                     Console.WriteLine("{0}:{1:00} hours after the start", timeInterval / 60, timeInterval - (timeInterval / 60) * 60);
  65.                 }
  66.             }
  67.         }
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement