teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

2

2020/05/24 17:15

投稿

ryotazumi
ryotazumi

スコア8

title CHANGED
File without changes
body CHANGED
@@ -95,7 +95,7 @@
95
95
 
96
96
  class Calculator {
97
97
  private boolean isOperator (String token) {
98
- if (token == "+" || token == "-" || token == "*" || token == "/") {
98
+ if (token.equals("+") || token.equals("-") || token.equals("*") || token.equals("/")) {
99
99
  return true;
100
100
  }
101
101
  else {

1

2020/05/24 17:15

投稿

ryotazumi
ryotazumi

スコア8

title CHANGED
File without changes
body CHANGED
@@ -127,10 +127,10 @@
127
127
  x = Double.parseDouble(a);
128
128
  y = Double.parseDouble(b);
129
129
  switch (s) {
130
- case "+": x = x + y;
130
+ case "+": x = x + y; break;
131
- case "-": x = y - x;
131
+ case "-": x = y - x; break;
132
- case "*": x = x * y;
132
+ case "*": x = x * y; break;
133
- case "/": x = y / x;
133
+ case "/": x = y / x; break;
134
134
  }
135
135
  a = String.valueOf(x);
136
136
  stack.push(a);