MiroslavKisov

SinoTheWalker

Nov 27th, 2017
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.37 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.Numerics;
  4.  
  5. namespace _01.SinoTheWalker
  6. {
  7.     public class StartUp
  8.     {
  9.         public static void Main()
  10.         {
  11.             string inputTime = Console.ReadLine();
  12.             BigInteger stepsNeeded = BigInteger.Parse(Console.ReadLine());
  13.             BigInteger timePerStep = BigInteger.Parse(Console.ReadLine());
  14.             var startTime = inputTime.Split(':').ToArray();
  15.             BigInteger totalTimeInSeconds
  16.                 = BigInteger.Parse(startTime[0]) * 3600
  17.                 + BigInteger.Parse(startTime[1]) * 60
  18.                 + BigInteger.Parse(startTime[2]);
  19.             BigInteger timeToGetHome = timePerStep * stepsNeeded;
  20.             totalTimeInSeconds += timeToGetHome;
  21.             BigInteger hours = (totalTimeInSeconds / 3600) % 24;
  22.             BigInteger minutes = (totalTimeInSeconds % 3600) / 60;
  23.             BigInteger seconds = (totalTimeInSeconds % 3600) % 60;
  24.             if (seconds > 59)
  25.             {
  26.                 minutes++;
  27.                 seconds = 0;
  28.             }
  29.             if (minutes > 59)
  30.             {
  31.                 hours++;
  32.                 minutes = 0;
  33.             }
  34.             if (hours > 23)
  35.             {
  36.                 hours = hours - 24;
  37.             }
  38.             Console.WriteLine($"Time Arrival: {hours:D2}:{minutes:D2}:{seconds:D2}");
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment