我只是编写一个基本代码,需要2个输入和一个运算符并解决.我必须编写程序代码,告诉它不要让0的除法发生,但我的其他人一直有一条错误消息,说有一个语法错误令牌.我不确定为什么,因为我过去做过if else语句,看起来并没有什么不同.我是编程新手.帮助将不胜感激
if((operator == '/') && (operand2 == 0))
JOptionPane.showMessageDialog(null,"Division by 0 not allowed");
System.exit(0);
else
add = operand1 + operand2;
mult = operand1 * operand2;
sub = operand1 - operand2;
div = operand1 / operand2;
remainder = operand1 % operand2;
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
1720 次 |
最近记录: |