Advertisement
Guest User

08_Traveling_at_Light_Speed

a guest
Apr 8th, 2017
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.98 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 _08_Traveling_at_Light_Speed
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal lightYears = decimal.Parse(Console.ReadLine());
  14.  
  15.             decimal timeT = (lightYears * 9450000000000M) / 300000M;
  16.  
  17.             decimal timeInWeeks = timeT / (60M * 60M * 24M * 7M);
  18.             decimal timeInDays = (timeT / (60M * 60M * 24M)) % 7;
  19.             decimal timeInHours = (timeT / (60M * 60M)) % 24;
  20.             decimal timeInMinutes = (timeT / (60M)) % 60;
  21.             decimal timeInSeconds = timeT % 60;
  22.  
  23.             Console.WriteLine("{0} weeks\n{1} days\n{2} hours\n{3} minutes\n{4} seconds",
  24.              Math.Floor(timeInWeeks),
  25.              Math.Floor(timeInDays),
  26.              Math.Floor(timeInHours),
  27.              Math.Floor(timeInMinutes),
  28.              Math.Floor(timeInSeconds));
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement