import java.util.*; import java.text.*; import javax.swing.*; class Lab4Part2{ public static void main (String[] args) { String ex1; Double num, F; final int a=0, b=0; JFrame myWindow=new JFrame(); myWindow.setSize(500,400); myWindow.setTitle("Calculator"); myWindow.setVisible(true); myWindow.setLocation(600,200); ex1=JOptionPane.showInputDialog(myWindow, "Enter an expression"); F=Double.parseDouble(ex1); num=(a+B); JOptionPane.showMessageDialog(myWindow, "The sum is "+num); } }
I need some help I keep getting an error when I try to run it on JGrasp. I have no clue what I'm doing wrong and for that matter I don't know what I have to do next if I am doing something wrong or not. However I'm trying to create a program where there are one input dialog that asking for the expression in "a+b" form like I would have to input "1+2" and then the second dialog would be a message giving the answer to that 1+2 which would show the message of 3. Thanks for helping.
PS. I believe the Double.parseDouble is a wrong method in solving this issue and I believe I need to stack but I don't know how.