I need to use two methods in my program which converts temperatures I have a problem with calling my method here is my code:
import java.io.*;
import javax.swing.JOptionPane;
public class Converter {
public static void main(String[] args) throws Exception{
//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String unit = JOptionPane.showInputDialog("Enter unit F or C: ");
String temp1 = JOptionPane.showInputDialog("Enter the Temperature: ");
double temp = Double.valueOf(temp1).doubleValue();
public static double convertTemp(){
if((unit.equals("F"))||(unit.equals("f"))){
double c= (temp - 32) / 1.8;
JOptionPane.showMessageDialog(null,c+" Celsius"));
}
else if((unit.equals("C"))||(unit.equals("c"))){
double f=((9.0 / 5.0) * temp) + 32.0;
JOptionPane.showMessageDialog(null,f+" Fahrenheit");
}
}
}