I don't know why this is not working I get no compilation error here but the program always returns the else statement. Am I supposed to define operation some other way or call it someway else?
import javax.swing.JOptionPane;
public class Calculator1 {
public static void main(String []Args) {
String firstNum;
String operation;
String secondNum;
firstNum = JOptionPane.showInputDialog("Input a number.");
secondNum = JOptionPane.showInputDialog("Input another number.");
double num1 = Double.parseDouble(firstNum);
double num2 = Double.parseDouble(secondNum);
operation = JOptionPane.showInputDialog("Input an operation sign.");
if (operation == "x") {
System.out.println( num1 * num2 );
}
if (operation == "*") {
System.out.println( num1 * num2 );
}
if (operation == "/") {
System.out.println( num1 / num2 );
}
if (operation == ":") {
System.out.println( num1 / num2 );
}
if (operation == "+") {
System.out.println( num1 + num2 );
}
if (operation == "-") {
System.out.println( num1 - num2 );
}
else {
System.out.println("Please enter an appropriate operation sign.");
}
} }