import javax.swing.JOptionPane;your text
public class Main {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null,"What Do You Want To Do?");
String typeOfMath = JOptionPane.showInputDialog("Addition, Subtraction, Division, Multiplication, Find The Square Root?");
String Addition;
String Subtraction;
String Division;
String Multiplication;
String SquareRoot;
double z;
if (typeOfMath == Addition) {
double x = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
double y = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
z = x + y;
JOptionPane.showMessageDialog(null, "The Answer Is: " + z);
}else if (typeOfMath == Subtraction) {
double x = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
double y = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
z = x - y;
JOptionPane.showMessageDialog(null, "The Answer Is: " + z);
}else if (typeOfMath == Division) {
double x = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
double y = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
z = x / y;
JOptionPane.showMessageDialog(null, "The Answer Is: " + z);
}else if (typeOfMath == Multiplication) {
double x = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
double y = Double.parseDouble(JOptionPane.showInputDialog("Enter First Number"));
z = x * y;
JOptionPane.showMessageDialog(null, "The Answer Is: " + z);
}else if (typeOfMath == SquareRoot){
double x = Double.parseDouble(JOptionPane.showInputDialog("Enter The Number"));
z = Math.sqrt(x);
JOptionPane.showMessageDialog(null, "The Answer Is: " + z);
}
}
}
Can Someone help it says that strings addition, subtraction etc might not be initialized.