공부하시는대에 도움이 됐으면 좋겠습니다.
답안코드 확인해주세요!
더보기
import java.util.Scanner;
public class Main {
public static String call(String input) {
String[] arr = input.split(" ");
int input1, input2;
input1 = Integer.parseInt(arr[0]);
input2 = Integer.parseInt(arr[2]);
if (arr[1].equals("+")) {
return arr[0] + " " + "+ " + arr[2] + " = " + (input1 + input2);
} else if (arr[1].equals("-")) {
return arr[0] + " " + "- " + arr[2] + " = " + (input1 - input2);
} else if (arr[1].equals("*")) {
return arr[0] + " " + "* " + arr[2] + " = " + (input1 * input2);
} else if (arr[1].equals("/")) {
return arr[0] + " " + "/ " + arr[2] + " = " + (input1 / input2);
} else {
return arr[0] + " " + arr[1] + " " + arr[2] + " = " + "0";
}
}
public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String input = in.nextLine();
System.out.println(call(input));
}
}
댓글