두개의 숫자와 연산자를 입력받아 연산결과를 알려주는 프로그램을 만들어주세요
Scanner input = new Scanner(System.in);
System.out.print("첫번째 숫자 입력 >");
int num1 = Integer.parseInt(input.nextLine());
System.out.print("연산자 입력 >");
String math = input.nextLine();
System.out.print("두번째 숫자 입력 >");
int num2 = Integer.parseInt(input.nextLine());
int result = math.equals("+") ? num1 + num2
: ( math.equals("-") ? num1 - num2
: ( math.equals("*") ? num1 * num2
: ( math.equals("/") ? num1 / num2
: null ) ) );
System.out.println(num1 + math + num2 + "=" + result);
삼항연산자 (?:)