Dear Shama:
Thank you for your help. One thing I am still comfucing is that when I input the expression, the input may be considered as string not integer. Last night, I was trying to make my program work. But I failed. Please give me some help to figure why my code can not be compiled.
Thank you.
HAIJUNpublic class Evaluator
{
public static void main(String [] args)
{
if (args.length == 0)
System.out.println("Missing Argument\n");
else
calculate(args[0], args[1], args[2]);
System.out.println("The answer is " + answers);
int calculate(int num1, String op, int num2)
{
int answers = 0;
if (op == "+")
{
answers = num1 + num2;
}
else if(op == "-")
{
answers = num1 - num2;
}
else if(op == "/")
{
if(num2 == 0)
{
display.setText("ERROR");
}
else
answers = num1 / num2;
}
else if(op == "*")
{
answers = num1 * num2;
}
return answers;
}//close calculate
}// close main
}// close class