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 trial

iOS Swift Basics (retired) Collections What is an Array?

Maher Alhasan
Maher Alhasan
974 Points

how 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.

I'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.

James Grider
James Grider
2,514 Points

What specifically are you having problems with in the exercise?

5 Answers

I imagine it would be something like this:

let celsius = (fahrenheit * 1.8) + 32
James Grider
James Grider
2,514 Points

You ever hear of "teach a man to fish"? Lol I upped your answer anyway.

i 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.

Hey, 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 :)

aaron bentley
aaron bentley
4,431 Points

Hey friend, This is how I have done mine.

import UIKit

var temperatureInFarenheit = 167

let temperatureInCelcius = (Double(temperatureInFarenheit) - 32) * (5/9)

println(temperatureInCelcius)