Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace DataBytes___Lab
- {
- class Program
- {
- static void Main(string[] args)
- {
- decimal lightYears = decimal.Parse(Console.ReadLine());
- decimal lightYearToKm = 9450000000000m;
- decimal speedOfLight = 300000m;
- decimal totalKm = lightYears * lightYearToKm;
- decimal totalSeconds = totalKm / speedOfLight;
- decimal weeks = totalSeconds / 604800;
- decimal weeksLeftOver = totalSeconds % 604800;
- decimal days = weeksLeftOver / (60 * 60 * 24);
- decimal daysLeftOver = weeksLeftOver % (60 * 60 * 24);
- decimal hours = daysLeftOver / 3600;
- decimal hoursleftOver = daysLeftOver % 3600;
- decimal minutes = hoursleftOver / 60;
- decimal seconds = hoursleftOver % 60;
- Console.WriteLine($"{Math.Floor(weeks)} weeks");
- Console.WriteLine($"{Math.Floor(days)} days");
- Console.WriteLine($"{Math.Floor(hours)} hours");
- Console.WriteLine($"{Math.Floor(minutes)} minutes");
- Console.WriteLine($"{Math.Floor(seconds)} seconds");
- // Assume that 1 light year == 9 450 000 000 000 km.
- // Assume that the speed of light == 300 000 km / second.
- }
- }
- }
Add Comment
Please, Sign In to add comment