I am having an issue with my current programming assignment. I feel as though I am very close to having it correct, but something is off. I know that I have to do something diff
Just use one specific unit to store the temperature internally, best would be Kelvin1 IMO (as it's the standard SI physical unit).
Do the necessary calculations when setting or getting the temperature as Fahrenheit or degrees Celsius.
Also don't use integer division to represent fractions:
(5/9)
will result as 0
integer division, it should be (5.0/9.0)
to get a valid double
value.
Same with 9/5
as integer division will result as 1
.
Further issues with your code:
double converter(double temperature)
you try to use f
, which isn't in scope theretemperature
, which shadows your member variable with the same name1)0K = -459,67F / 0K = -273.15°C