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 trialMIK Agency
22,496 PointsHow can I transform the grade from fahrenheit to celcius in the app called Build a weather app.
I want to transform from Fahrenheit to Celcius how it is possible
3 Answers
Stephen Goodwin
5,479 PointsPersonally I would add a line in the getTemperature in the CurrentWeather.java This line converts the decimal F to a decimal C then rounds the C to a whole number.
public int getTemperature() {
mTemperature = ((mTemperature -32)*5)/9;
return (int)Math.round(mTemperature);
}
Axel McCode
13,869 PointsHi Mik!
I made a small method that takes in the int value of the temperature in Fahrenheit and returns the value in degrees Celsius. Hope this helps :)
public int toCelsius(int fahrenheit) {
return ((fahrenheit - 32)*5)/9;
}
wajd tohme
10,240 Pointsadd a units query parameter to the forecast URL with a value of si, like this: "https://api.forecast.io/forecast/"+apiKey+ "/"+latitude+","+longitude+"?units=si"; this will return all data in si units, including celsius for temperature.
David GΓ³mez
4,389 PointsThanks for posting that reply, I was trying to do the same and the forecast.io API documents indicate the options, but I didn't know where to put the query parameter.