728x90 반응형 자바 if문1 자바 if문 예제 연산자 활용 public static void main(String[] args) { int a1, a2; String op; double res; Scanner sc = new Scanner(System.in); System.out.println("첫번째 정수 입력:"); a1 = sc.nextInt(); System.out.println("두번째 정수 입력:"); a2 = sc.nextInt(); sc.nextLine(); System.out.println("연산자 입력(덧셈:+, 뺄셈:-, 곱셈:*, 나눗셈:/):"); op = sc.nextLine(); if( op.equals("+") ) res = a1 + a2; else if( op.equals("-") ) res = a1 - a2; else if( op.. 2019. 7. 25. 이전 1 다음 728x90 반응형