So it works correctly but it is a bit confusing I would like to remove JOptionPane.showOptionDialog and simply add 2 buttons so that it is not so confusing in the code.............
I have tried with JButtons but could not make it And more than anything that fulfills the function of throwing the result
How can I use two buttons instead of JOptionPane.showOptionDialog?
float n, r;
int a = 1;
String input;
//Button content
Object[] options1 = {"°C -> °F", "°F -> °C", "Exit"};
int menu = JOptionPane.showOptionDialog(null, a + ". Select your conversion",
"Temperature scale selection",
JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.PLAIN_MESSAGE,
null, options1, null);
//Button 2
if (menu == JOptionPane.YES_OPTION) {
//Celsius to Fahrenheit
input = JOptionPane.showInputDialog("Enter degrees Celsius: ");
n = Integer.parseInt(input);
r = ((9 * n) / 5) + 32;
JOptionPane.showMessageDialog(null, r + " Fahrenheit");
} else if (menu == JOptionPane.YES_NO_CANCEL_OPTION) { //Button 3
//Fahrenheit to Celsius
input = JOptionPane.showInputDialog("Enter degrees Fahrenheit ");
n = Integer.parseInt(input);
r = (n - 32) * 5 / 9;
JOptionPane.showMessageDialog(null, r + " Celsius");
}