Rectangle 27 0

java Celsius to Fahrenheit Converter GUI program?

FahrenheitButtonHandler btnHandlerFahrenheit = new FahrenheitButtonHandler();
celsius = (5 / 9) * (fahrenheit - 32);
celsius = Math.round((5 / (float)9)) * (fahrenheit - 32);
celsius1 = Integer.parseInt(fldFahrenheit.getText());
fahrenheit1 = celsius1*(9/5)+32;

...but remember, there is still the interger division problem you need to correct for this...

If 5/9 = 0 as the resulting value is converted to an integer.

Ignoring the code issues that make the example uncompliable...

In your FahrenheitButtonHandler class, you are also applying the wrong value to the text field...

Now, personally, I would be using a double or float instead of an int and formatting the result but that's me. You'll need to do the same thing FahrenheitButtonHandler

You applying the celsius1 value, which is the value your extract from the fldFahrenheit field, not the calculated result, it should be

You have an integer division problem...