Advertisement
braveheart1989

CenturiesToNanosec

May 19th, 2016
977
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 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.Numerics;
  7. namespace _02.CenturiesToNanosec
  8. {
  9.     class CenturiesToNanosec
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             //Write program to enter an integer number of centuries and convert it to years, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds
  14.  
  15.             int centuries = int.Parse(Console.ReadLine());
  16.             int years = centuries * 100;
  17.             int days = (int)(years * 365.2422);
  18.             int hours = days * 24;
  19.             decimal minutes = hours * 60M;
  20.             decimal seconds = minutes * 60M;
  21.             decimal milliseconds = seconds * 1000M;
  22.             decimal microseconds = milliseconds * 1000;
  23.             decimal nanoseconds = microseconds * 1000;
  24.             Console.WriteLine("{0} centuries = {1} years = {2} days = {3} hours = {4} minutes = {5} seconds = {6} milliseconds = {7} microseconds = {8} nanoseconds", centuries, years, days, hours, minutes, seconds, milliseconds, microseconds, nanoseconds);
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement