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

Fahrenheit to Celsius converter using operators

I am trying to make a celsius to Fahrenheit converter using swift. I just finished the operators step on the course and i'm wondering how to fix it.

var fahrenheit = 10

var celsius :Double = 5/9(fahrenheit-32)

fahrenheit

Basically i start with 10 degrees fahrenheit. The i do 5/9(10-32). I get an error on that line. I am not sure what is wrong here.

1 Answer

you probably need to use the multiplication operator which is *. you might also need to put 5/9 in parenthesis.

var celsius :Double = (5/9) * (fahrenheit-32)

in most programming languages you have to be explicit with multiplication, you cant use parenthesis to mean multiplication like you can in algebra and what not