svetliovd

Traveling at Light Speed

Jun 2nd, 2017
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.27 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 TravellingAtLightSpeed
  8. {
  9.     class TravellingAtLightSpeed
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal lightYears = decimal.Parse(Console.ReadLine());
  14.             decimal time = lightYears * 9450000000000 / 300000;
  15.  
  16.  
  17.             decimal weeks = time / 60 / 60 / 24 / 7;
  18.             decimal weeksFormated = Math.Floor(weeks);
  19.  
  20.             decimal days = (weeks - weeksFormated) * 7;
  21.             decimal daysFormated = Math.Floor(days);
  22.  
  23.             decimal hours = (days - daysFormated) * 24;
  24.             decimal hoursFormated = Math.Floor(hours);
  25.  
  26.             decimal minutes = (hours - hoursFormated) * 60;
  27.             decimal minutesFormated = Math.Floor(minutes);
  28.  
  29.             decimal seconds = (minutes - minutesFormated) * 60;
  30.             decimal secondsFormated = Math.Floor(seconds);
  31.  
  32.             Console.WriteLine($"{weeksFormated} weeks");
  33.             Console.WriteLine($"{daysFormated} days");
  34.             Console.WriteLine($"{hoursFormated} hours");
  35.             Console.WriteLine($"{minutesFormated} minutes");
  36.             Console.WriteLine($"{secondsFormated} seconds");
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment