2013-04-10 15:42:53 -07:00
|
|
|
import java.util.Scanner;
|
|
|
|
|
|
2017-09-23 10:01:46 +02:00
|
|
|
public class IntegerArithmetic {
|
|
|
|
|
public static void main(String[] args) {
|
|
|
|
|
Scanner sc = new Scanner(System.in);
|
|
|
|
|
int a = sc.nextInt();
|
|
|
|
|
int b = sc.nextInt();
|
|
|
|
|
|
|
|
|
|
int sum = a + b; // integer addition is discouraged in print statements due to confusion with string concatenation
|
|
|
|
|
System.out.println("a + b = " + sum);
|
|
|
|
|
System.out.println("a - b = " + (a - b));
|
|
|
|
|
System.out.println("a * b = " + (a * b));
|
|
|
|
|
System.out.println("quotient of a / b = " + (a / b)); // truncates towards 0
|
|
|
|
|
System.out.println("remainder of a / b = " + (a % b)); // same sign as first operand
|
|
|
|
|
}
|
2013-04-10 15:42:53 -07:00
|
|
|
}
|