Created
May 3, 2020 03:18
-
-
Save geektutor/d8f5498fe791044d9911e0b4e2446d23 to your computer and use it in GitHub Desktop.
Day 2 of 30DaysOfCode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void main() { | |
/* | |
Day 2 - Space Age Given an age in seconds, calculate how old someone would be on: Mercury: orbital period 87.97 Earth days Venus: orbital period 224.7 Earth days Earth: orbital period 365.25 Earth days Mars: orbital period 686.93 Earth days Jupiter: orbital period 4,330.6 Earth days Saturn: orbital period 10,755.7 Earth days Uranus: orbital period 30,687 Earth days Neptune: orbital period 60,190 Earth days So if you were told someone was 631152000 seconds old, you should be able to say that they're 31.69 Earth-years old, 83.04 Mercury-years old. | |
*/ | |
age(631152000); | |
} | |
age(age) { | |
double year = age / 86400; | |
String mercury = (year / 87.97).toStringAsFixed(2); | |
String venus = (year / 224.7).toStringAsFixed(2); | |
String earth = (year / 365.25).toStringAsFixed(2); | |
String mars = (year / 686.93).toStringAsFixed(2); | |
String jupiter = (year / 4330.6).toStringAsFixed(2); | |
String saturn = (year / 10755.7).toStringAsFixed(2); | |
String uranus = (year / 30687).toStringAsFixed(2); | |
String neptune = (year / 60190).toStringAsFixed(2); | |
print('$mercury mercury years old'); | |
print('$venus venus years old'); | |
print('$earth earth years old'); | |
print('$mars mars years old'); | |
print('$jupiter jupiter years old'); | |
print('$saturn satuen years old'); | |
print('$uranus uranus years old'); | |
print('$neptune neptune years old'); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment