LearningProcessing icon indicating copy to clipboard operation
LearningProcessing copied to clipboard

07-08 Fahrenheit

Open TKerem opened this issue 8 years ago • 5 comments

I can't understand the Exercise 7-8

Please help me to find the solution.

This is my code, but the result is always 0.0

void setup (){ size(200,200); }

void draw () { float result = convertToCelsius(100); println(result); }

float convertToCelsius(float F){ float c = (F - 32) * (5/9); return c; }

TKerem avatar Jul 02 '17 19:07 TKerem

Try with all numbers floats.

100.0, 32.0, 5.0, 9.0 May be the error. Try to "debug" your program. Print the F in the beginin of convertToCelsius() (before float c...), print c after this line. Ah! don't put variables in uppercase.

itubal avatar Jul 03 '17 08:07 itubal

The skect doesn't work. I try a lot of numbers but I don't understand where is the problem.

TKerem avatar Jul 03 '17 09:07 TKerem

did you make the corrections that I wrote? What is the value of "c" ?

2017-07-03 11:26 GMT+02:00 TKerem [email protected]:

The skect doesn't work. I try a lot of numbers but I don't understand where is the problem.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/shiffman/LearningProcessing/issues/211#issuecomment-312595929, or mute the thread https://github.com/notifications/unsubscribe-auth/AAAuj53-rGzUaAUlyGzZVgQb1-ERzk8vks5sKLO9gaJpZM4OLqhS .

-- José María @itubalibre http://itubal.github.io/ http://itubalstyle.blogspot.com

itubal avatar Jul 03 '17 12:07 itubal

I have the answer here:

void draw(){ float answer = tempConverter(46); println(answer); }

float tempConverter(float f){ float c = (f - 32.0)*(5.0/9.0); return c; }


the float values must have decimals so they can be read properly.

:)

ghost avatar Jul 22 '17 20:07 ghost

Thanks !!

TKerem avatar Jul 23 '17 14:07 TKerem