大鸟简单问题,可我不明白!!
import javax.swing.JOptionPane;import javax.swing.JFrame;
public class C extends JFrame{
double ca()
{
String str=JOptionPane.showInputDialog("请输入第一个数");
double a=Double.parseDouble(str);
String str1=JOptionPane.showInputDialog("请输入要进行的运算符号!");
String str2=JOptionPane.showInputDialog("请输入第二个数");
double b=Double.parseDouble(str2);
if(str1="+")
{
JOptionPane.showMessageDialog(this,a+b,"加法的结果",JOptionPane.INFORMATION_MESSAGE);
}
else if(str="-")
{
JOpationPane.showMessageDialog(this,a-b,"减法结果",JOptionPane.INFORMATION_MESSAGE);
}
else if(str="/")
{
JOpationPane.showMessageDialog(this,a/b,"除法结果",JOptionPane.INFORMATION_MESSAGE);
}
else if (str="*")
{
JOpationPane.showMessageDialog(this,a*b,"乘法结果",JOptionPane.INFORMATION_MESSAGE);
}
else
{
JOptionPane.showMessageDialog(this,warning,"请输入合法的计算",JOptionPane. WARNING_MESSAGE);//在这个位子报错了。不理解啊!!
}
public static void main(String[] args)
{
C s1=new C();
s1.ca();
}
}