※할당 연산자(Assignment Operators)
예제) ArithTest.java
import java.util.Scanner;
public class ArithTest {
public static void main(Sting[] args) {
Scanner sc = new Scanner(System.int);
System.out.print("첫번째 정수 입력하세요 : ");
int input1 = sc.nextInt();
System.out.print("두번째 정수 입력하세요 : ");
int input2 = sc.nextInt();
int sum = input1+input2;
int sub = input1-input2;
int multi = input1*input2;
int div = input1/input2;
int mod = input1%input2;
System.out.print("첫번째 정수: %d + 두번째 정수: %d = %d\n",input1, input2, sum);
System.out.print("첫번째 정수: %d - 두번째 정수: %d = %d\n",input1, input2, sub);
System.out.print("첫번째 정수: %d * 두번째 정수: %d = %d\n",input1, input2, multi);
System.out.print("첫번째 정수: %d / 두번째 정수: %d = %d\n",input1, input2, div);
System.out.print("첫번째 정수: %d %% 두번째 정수: %d = %d\n",input1, input2, mod);
}
}

예제) ComplexArith01.java
public class ComplexArith01 {
public static void main(Sting[] args) {
int intValue=1/2;
System.out.printf("%d",intValue);
System.out.println("");
double realValue1=1/2.0;
System.out.printf("%.2f\n",realValue1);
double realValue2=1.0/2;
System.out.printf("%.2f\n",realValue2);
double realValue3=1.0/2.0;
System.out.printf("%.2f\n",realValue3);
}
}
