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 trialMaher Alhasan
974 Pointshow can i do this exercise?
Using the math operators taught in this stage create a formula to change any given temperature from Fahrenheit to Celsius.
James Grider
2,514 PointsWhat specifically are you having problems with in the exercise?
5 Answers
Jason Lysinger
1,365 PointsI imagine it would be something like this:
let celsius = (fahrenheit * 1.8) + 32
James Grider
2,514 PointsYou ever hear of "teach a man to fish"? Lol I upped your answer anyway.
Kevin Leadbetter
1,153 Pointsi was having some trouble with this extra credit also so went with the following :
var tempInFahrenheit = 0
let celsius = ( tempInFahrenheit -32) * 5/9
hope this is of help to you.
William Davis
5,497 PointsHey, Maher. Try this:
var fahr = 0.0
let celc = (fahr - 32.0) / 1.8
println(celc)
Then substitute in fahr the temperature you want to have converted into Celcius. Don't forget to write it like a double (using at least once decimal, ie: 1.0) for it to work :)
Maher Alhasan
974 PointsThanks everyone
aaron bentley
4,431 PointsHey friend, This is how I have done mine.
import UIKit
var temperatureInFarenheit = 167
let temperatureInCelcius = (Double(temperatureInFarenheit) - 32) * (5/9)
println(temperatureInCelcius)
Vincent K
3,356 PointsVincent K
3,356 PointsI'm not doing the Swift course, but have a look at this:https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Initialization.html Might be a help. Also check whether this has been asked before with google search.