what is wrong here?
Double TC;
TC=(celsius-32) * 5/9;
return TF;
what does return actually do and what are we returning from this method?>
confused about doing this task
Under discussion
Comments (5)
- Popular
- New
- Old
You must be signed in to leave a comment
palve72
22 December 2018, 20:54
The problem asks for a double that represents the value in Fahrenheit degrees. I solved the problem using the formula: TF = (TC * 9.0/5.0) + 32 because that will return such value.
I think the problem tricks you into thinking that you need to use the formula for TC, but it's only there to show you the relationship as a reference so you can figure it out from there.
0
Aswini
10 December 2018, 17:50
I understood, thank u
0
Syed Tayyab ul Mazhar
30 December 2018, 10:53
Then mark the question as resolved.
0
Guadalupe Gagnon
10 December 2018, 17:14
(Along with what Khurram said about returning the correct variable)
You are using ints instead of doubles in your equation. The conversion to a double happens after the equation evaluates, thus it drops off anything after the decimal. Make one of the changes below and your code will work properly:
or
0
Khurram
10 December 2018, 16:50
return is used to return any value from a method, here you have declared and initialized a variable TC but are returning a variable TF which is not declared in the method
0