I'm just learning Java for fun and found this forum very usefull some of the time! :)
Now, I have a problem, I can't get an application to do what I want it to do.. I just want it to run "choice" , then from my input choice I want it to run e.g ovning3 (which is "converter") but it just exits after I type in my choice "3" ..
Anything I did wrong? This is my first app with several "instances".. Is my logic is wrong?
import static javax.swing.JOptionPane.*;
public class Ovningar {
public static void main(String[] args) {
choice();
}
public static void choice(){
String input = showInputDialog("Välj övning");
if (input == "3")
converter();
if (input == "4")
sfer();
}
public static void sfer() {
}
public static void converter() {
String input[] = showInputDialog("Mile/Gallons?").split("/");
String strmiles = input[0];
String strgallon = input[1];
double miles = Double.parseDouble(strmiles);
double gallon = Double.parseDouble(strgallon);
double km = miles*1.609;
double liter = gallon*3.785;
showMessageDialog(null, km+"/"+liter);
}
}