grach

TimeOfExam_WithENTER

Feb 16th, 2020
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.05 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 TimeOfExam
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.  
  13.         {
  14.             Console.Write("Exam start at: ");
  15.             Console.WriteLine(DateTime.Now.ToString("HH:mm:ss"));
  16.             Console.Write("press ENTER to see examimg time");
  17.                                                                                          //Console.WriteLine("Enter FIRST time: for example:hour: min:sec 15:25:10");
  18.                                                                                          //DateTime firstTime = DateTime.Now.ToString("h:mm:ss tt");
  19.             DateTime firstTime = new DateTime();
  20.             firstTime = DateTime.Parse(DateTime.Now.ToString("h:mm:ss tt"));
  21.                                                                                             //firstTime = DateTime.Parse(Console.ReadLine());
  22.  
  23.                                                                                             //Console.WriteLine("Enter LAST time: for example:hour:  min:sec 15:25:10");
  24.             Console.ReadLine();
  25.  
  26.             Console.Write("Exam finish at: ");
  27.             Console.WriteLine(DateTime.Now.ToString("HH:mm:ss"));
  28.             DateTime secondTime = new DateTime();                      
  29.             secondTime = DateTime.Parse(DateTime.Now.ToString("h:mm:ss tt"));
  30.  
  31.          
  32.  
  33.  
  34.             if (secondTime < firstTime)
  35.             {
  36.                 TimeSpan difference = (firstTime - secondTime);
  37.                 difference -= TimeSpan.FromHours(24);
  38.                 difference = difference.Duration();
  39.                 Console.WriteLine("Time of Exam: {0} hour:min:sec ", difference);
  40.  
  41.  
  42.             }
  43.             else if (secondTime > firstTime)
  44.             {
  45.                 TimeSpan difference = (secondTime - firstTime);
  46.                 Console.WriteLine("Time of Exam: {0} hour:min:sec", difference);
  47.  
  48.             }
  49.             Console.ReadLine();
  50.  
  51.         }
  52.  
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment