Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
morning code challenge week 14
- (NSString* )ageOnDifferentPlanet:(double)seconds {
double earthYears = seconds / 31557600.0;
double mercuryYears = earthYears / 0.2408467;
double venusYears = earthYears / 0.61519726;
double marsYears = earthYears / 1.8808158;
double jupiterYears = earthYears / 11.862615;
double saturnYears = earthYears / 29.447498;
double uranusYears = earthYears / 84.016846;
double neptuneYears = earthYears / 164.79132;
return [NSString stringWithFormat:@"Earth: %.2f years, Mercury: %.2f years, Venus: %.2f years, Mars: %.2f years, Jupiter: %.2f years, Saturn: %.2f years, Uranus: %.2f years, Neptune: %.2f years", earthYears, mercuryYears, venusYears, marsYears, jupiterYears, saturnYears, uranusYears, neptuneYears];
}
NSString *printStatement = [self ageOnDifferentPlanet:31557600.0];
NSLog(printStatement);
@PaulSolt

This comment has been minimized.

Copy link

commented Oct 10, 2019

always write: (NSString *)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.