Last active
January 4, 2016 21:19
-
-
Save casspangell/8679988 to your computer and use it in GitHub Desktop.
write a function that prints a rating between zero and four stars. ratings can be half stars (two and a half for example). full stars should be represented by an asterisk (*) and half stars should be represented by a period (.)
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
(NSString*)ratingFunction(int):rating{ | |
int halfStars = rating - floor(rating); | |
int fullStars = floor(rating); | |
NSString *rateString; | |
while(fullStars > 0){ | |
rateString = [rateString stringByAppendingString:@"*"; | |
fullStars --; | |
} | |
if(halfStars != 0){ | |
rateString = [rateString stringByAppendingString:@"."; | |
} | |
return rateString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment