1. 문제
2. 코드
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
int lineCnt = 1;
int result = n;
String s = "";
while (!s.equals("=")) {
lineCnt++;
if (lineCnt % 2 != 0) {
n = Integer.parseInt(br.readLine());
switch(s) {
case "+":
result += n;
break;
case "-":
result -= n;
break;
case "*":
result *= n;
break;
case "/":
result /= n;
break;
default:
break;
}
} else {
s = br.readLine();
}
}
System.out.println(result);
}
}
3. 링크
https://www.acmicpc.net/problem/5613