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

Android Build a Weather App (2015) Hooking Up the Model to the View Setting the Weather Icon

James N
James N
17,864 Points

decimal values still showing!

in the app, the decimals for precipitation and temperature are still showing. (except they are always 0s) thanks in advance!!

2 Answers

Eric De Wildt
PLUS
Eric De Wildt
Courses Plus Student 13,077 Points

If you return a double it will always add the .0 at the end. You want to return an int like this:

public int getTemp() {
        return (int)Math.round(mTemp);
     }
James N
James N
17,864 Points

Thanks for your help, eric! this fixed everything!

Slava Fleer
Slava Fleer
6,086 Points

did you cast values in getters to int ?

James N
James N
17,864 Points

this is my get temp method:

getTempMethod.java
  public double getTemp() {
        return (int)Math.round(mTemp);
     }

but the funny thing is: I didn't get an error when I typed the code BEFORE I added the int cast.

Stefan Kaczmarek
Stefan Kaczmarek
21,228 Points

James, you need to set the return type of getTemp() to int instead of double.