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 trialJames N
17,864 Pointsdecimal 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
Courses Plus Student 13,077 PointsIf 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);
}
Slava Fleer
6,086 Pointsdid you cast values in getters to int ?
James N
17,864 Pointsthis is my get temp method:
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
21,228 PointsJames, you need to set the return type of getTemp() to int instead of double.
James N
17,864 PointsJames N
17,864 PointsThanks for your help, eric! this fixed everything!