Write a program which tells you:
- how many hours are in a year?
- how many minutes are in a decade?
- how many seconds old are you?
Code:
puts 24*365, 60*24*365*10, (60*60)*((365*32)+(30*8))
Output:
8760
5256000
42912000
Harder: If I am 1031 million seconds old, how old am I?
minutes = 1031000000/60
puts '1,031,000,000 seconds = ' + minutes.to_s + ' minutes'
hours = minutes/60
puts 'or ' +hours.to_s + ' hours'
days = hours/24
puts 'or ' + days.to_s + ' days'
years = days/365.25
puts 'or ' + years.to_s + ' years'
Output:
1,031,000,000 seconds = 17183333 minutes
or 286388 hours
or 11932 days
or 32.6680355920602 years
Notes: Not sure why the decimals are different from perl.