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
Marco Aniello
3,297 PointsWhat's wrong with my formula; converting Farenheit to Celcius
Hi Im doing the challenge at the end of the Operators stage. The challenge is: "Using the math operators taught in this stage create a formula to change any given temperature from Fahrenheit to Celsius."
When I do it I get lots of errors. This is how I start my formula
var farenheit: Double = 100 // assuming its 100 degrees out. I made double for percentages
var celcius: Double = (farenheit (-32)*5/9)
I get the error: (IntegerLiteralConvertible) -> $T4 is not identical to 'Double'
var celcius: Double = (farenheit (-32)*5/9)
Now I can fix it by writing it all out without shortcuts below:
var farenheit: Double = 100
var celcius = farenheit - 32
var temperature = celcius * 5/9
print("The temperature from \(farenheit) is \(temperature) Celcius")
But thats not exactly what the challenge is. Can anyone tell me whats wrong with this formula:
var celcius: Double = (farenheit (-32)*5/9)
thanks!
3 Answers
Marco Aniello
3,297 Pointsthanks, but even if I take the "Double" out it still gives an error. Even if I dont specify the type of variable and I rename it 100.0 and 32.0, 5.0,9.0 so they are no longer int it still errors Id love to know the correct way to solve this problem. thanks
Marlon Henry
6,885 Points100 is not a double that's a int.
Lukes Ivi
2,001 PointsI'm having the same problem Marco. One of the problems is that it's not negative 32 (-32) as you specified. I did the same thing. Still not working for me. Here's my code:
var conversionFormula: Double = (32) * 5 / 9
var fahrenheit = 100.00
var answer = fahrenheit - conversionFormula
I'm debating on where does the (F - the conversion) go. The - can't go in front of the conversionFormula var because then it just negates everything than. I need to somehow make it so fahrenheit - conversation formula = the temperature whenever i change it.
No idea. Really bothering me... Any ideas?