import javax.swing.*; public class Temperature3 { private static double convertedValue = 0.0; private static char convertedScale = 'F'; public static void convert(double value, char scale) { if (scale == 'F') { convertedValue = 5.0/9.0*(value - 32.0); convertedScale = 'C'; } else if (scale == 'C') { convertedValue = 9.0/5.0*value + 32.0; convertedScale = 'F'; } else { convertedValue = -1.0; convertedScale = 'I'; } } private static void main(String args[]) { String valueS = JOptionPane.showInputDialog("Temp value:"); String scaleS = JOptionPane.showInputDialog("Temp scale:"); double value = Double.parseDouble(valueS); char scale = scaleS.toUpperCase().charAt(0); convert(value, scale); JOptionPane.showMessageDialog(null, value + " " + scale + " = " + convertedValue + " " + convertedScale); } }