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


Lukas Baumgartner
Lukas Baumgartner
14,817 Points

Weather App temperature problem

Hey guys,

i followed the course on how to create a weather app. Everything works as it should. Well except for one thing... Since I'm from Europe, i want to display my temperature in degree celsius, not degree fahrenheit.

I searched for the right way to convert the temperature from F to C, but I'm constantly 2-8 degrees off... Here's the way i convert it:

public int getTemperature() {
        double degreeCelsius = ((mTemperature - 32) * 0.55556);
        return (int)Math.round(degreeCelsius);

I use the forecast API to get the data. I thought that maybe because of the API the temperature is wrong, but I checked the homepage forecast.io and the temperature of my hometown matches other forecast sites. My app, however, displays it wrong.

3 Answers

Lukas Baumgartner
Lukas Baumgartner
14,817 Points

I've found what was wrong :D

The way I converted the temperature was right, but I used the wrong coordinates in my API... Pretty stupid. But now it works fine!

6,509 Points

Use this logic:

temperatue = ((temperatue - 32)*5)/9;

It will give you the degree in Celsius.

Hope it helps!

Happy Coding!

Lukas Baumgartner
Lukas Baumgartner
14,817 Points

Unfortunatly not...

When I do it your way, it screws up my temperature displayed in a recycler view... Everytime I scroll down, the most top temperature gets redone and after a while i get rediculously low temperatures :D Don't ask me why or how...

I moved back to my implementation. I keep you updatet on how or if i solved the problem :)