別のJTextフィールドから2つの入力を計算し、コンボボックスで演算子を選択し、選択した演算子に基づいて結果を計算する必要があります。しかし、私は答えとして0を得る。 0を得ることなく結果をどのように計算できますか?計算機の結果をJavaで取得する
private void jButton1_actionPerformed(ActionEvent e) {
int x = Integer.parseInt(jTextField1.getText());
int y = Integer.parseInt(jTextField2.getText());
String Result = "0";
jLabel4.setText(Result);
int total = Integer.parseInt(Result);
if(Operator.equals("+")) {
total = x + y;
}
else if(Operator.equals("-")) {
total = x - y;
}
else if(Operator.equals("*")) {
total = x * y;
}
else if(Operator.equals("/")) {
total = x/y;
}
}