Advertisement
georgimanov

01 ExamSchedule

Apr 14th, 2014
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.43 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. using System.Threading;
  8.  
  9.  
  10. namespace _1.Problem
  11. {
  12.     class Program
  13.     {
  14.         static void Main(string[] args)
  15.         {
  16.             CultureInfo enUS = new CultureInfo("en-US");
  17.             DateTime time = new DateTime();
  18.             double hour = double.Parse(Console.ReadLine());
  19.             double minutes = double.Parse(Console.ReadLine());
  20.             time = time.AddMinutes(minutes);
  21.  
  22.             string amOrPm = Console.ReadLine();
  23.             switch (amOrPm)
  24.             {
  25.                 case "AM": hour = hour + 0; break;
  26.                 case "PM" : hour = hour + 12; break;
  27.                 default:
  28.                     break;
  29.             }
  30.             time = time.AddHours(hour);
  31.  
  32.             double additionaHours = double.Parse(Console.ReadLine());
  33.             time = time.AddHours(additionaHours);
  34.  
  35.             double additionalMinutes = double.Parse(Console.ReadLine());
  36.             time = time.AddMinutes(additionalMinutes);
  37.  
  38.             string stramOrPm ;
  39.                 if (time.Hour < 12)
  40.                 {
  41.                     stramOrPm = "AM";
  42.                 }
  43.            else
  44.                 {
  45.                     stramOrPm = "PM";
  46.                 }
  47.  
  48.  
  49.             Console.WriteLine(time.ToString("hh:mm:") + "{0}", stramOrPm);
  50.  
  51.         }
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement