Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialsurya m
542 Pointswhat's wrong in my code?
Create a method called 'calculateTip' that takes a float variable called 'subtotal' as a parameter, multiplies that value times 0.2 and returns a float value.
-(void)calculateTip = (subtotal*0.2);
1 Answer
Antoine Barthelet
3,738 Pointsfunctions in objective C follow a format: -(return type of function) function name: (input 1 type) Input_1_name andInput_2_name:(input 2 type) Input_2_name{ function code }
So in your case, the answer would be: -(float) calculateTip: (float) subtotal{return subtotal*0.2;}
surya m
542 Pointssurya m
542 PointsThank you Antoine!