hello, it's me again.
As you have noticed, i am working on an assignment that my teacher gave me. It's 20% of my midterm exam. I posted the threads "Need urgent help! please", "I need help with my program", and the "Help with my main method."
I am having problems again with my main method.
public static void main(String args[]) {
boolean stop = false;
JOptionPane.showMessageDialog(null, "Hello! I hope you have a wonderful time using the calculator. = ]", "Welcome", JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "Note: \nEnter Infix expressions with spaces in between.", "Welcome", JOptionPane.PLAIN_MESSAGE);
while (!stop){
String infix = JOptionPane.showInputDialog("Enter Mathematical expression here:");
String output = "The expression in Postfix is: " + convertToPostfix(infix);
JOptionPane.showMessageDialog(null, output);
String answer = "The answer to the equation: " + evaluate(convertToPostfix(infix));
JOptionPane.showMessageDialog(null, answer);
int option = JOptionPane.showConfirmDialog(null,"Do you want evaluate an expression?", "Calculator", JOptionPane.YES_NO_OPTION);
if (option == 1){
stop = true;
}
}JOptionPane.showMessageDialog(null, "Thank you for using the calculator.\n Have a nice day!\nGob Bless = ]");
}
}
This is how it suppose to do:
while(true){
//get input
//show postfix
//show answer
//asks the user to that if he wants to input again
if YES do the while loop again. if NO, exit while and ouput "thank you for using the calculator
}
but it seems that even if NO is your answer, it still asks an input.. what changes should i do??