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 trialGamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsRecap: Functions
Hi guys, I have been really stuck with this question and still do not understand how I should write the code for converting fahrenheit to celsius. Can someone help me? Thanks.
func temperatureInFahrenheit(temperature: Double) -> Double {
temperatureInFahrenheit
}
1 Answer
Scott Lougheed
19,390 PointsHi GamingWithHan, So you've got the function declared, you've got to fill it in with the actual tasks you want it to perform. I don't want to just give you the answer but here's some guidance
Have you been able to pass the first part of the challenge? (remember, to pass the first part of the challenge you have to add
return temperature
as a placeholder which you will be removing in the next step.
Once you pass step 1, in step two, you have to fill in the actual arithmetic to do the conversion. The instructions tell you the math needed (remember the order of operations!):
Take the temperature in Celsius (passed into the function as the 'temperature' variable), multiplied by 9, the product of which is divided by 5, to which you add 32. The math (with parentheses to force the correct order of operations) should look roughly this:
((temperature*9)/5)+43
(where "temperature" is the variable temperature passed into the function)
This would have to be assigned to a constant that you return in the next line of code.
Does that help?
GamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsGamingWithHan :)
Java Web Development Techdegree Student 1,966 PointsThanks Scott so much! Also, I was able to pass the first task.
Scott Lougheed
19,390 PointsScott Lougheed
19,390 PointsGreat I'm glad you were able to get things sorted out. If you have any other trouble I'm sure the community would be happy to help!