Please help with this. I am very new to this, and I need this badly. I need to create a program where it lets you choose from addition or subtraction. This is my current program:
import javax.swing.JOptionPane;
public class RationalZ {
public static void main(String args[]) {
JOptionPane.showMessageDialog(null,
"Enter the letter A for Addition and B Subtraction");
String choice = JOptionPane.showInputDialog(
"A=Addition B=Subtraction");
if (choice == "a") {
String strNum1 = JOptionPane.showInputDialog(
"Enter a Number");
String strNum2 = JOptionPane.showInputDialog(
"Enter a second number");
int aNum1 = Integer.parseInt(strNum1);
int aNum2 = Integer.parseInt(strNum2);
JOptionPane.showMessageDialog(null, aNum1 + aNum2);
System.exit(0);
} else {
System.exit(0);
}
}
}
What's wrong? Even in the first step I can't get it.