June 2018 Update
This commit is contained in:
parent
ba8067c3b7
commit
22f33d4004
5278 changed files with 84726 additions and 14379 deletions
|
|
@ -2,15 +2,21 @@ import java.util.Scanner;
|
|||
|
||||
public class IntegerArithmetic {
|
||||
public static void main(String[] args) {
|
||||
// Get the 2 numbers from command line arguments
|
||||
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
|
||||
int sum = a + b; // The result of adding 'a' and 'b' (Note: integer addition is discouraged in print statements due to confusion with string concatenation)
|
||||
int difference = a - b; // The result of subtracting 'b' from 'a'
|
||||
int product = a * b; // The result of multiplying 'a' and 'b'
|
||||
int division = a / b; // The result of dividing 'a' by 'b' (Note: 'division' does not contain the fractional result)
|
||||
int remainder = a % b; // The remainder of dividing 'a' by 'b'
|
||||
|
||||
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
|
||||
System.out.println("a - b = " + difference);
|
||||
System.out.println("a * b = " + product);
|
||||
System.out.println("quotient of a / b = " + division); // truncates towards 0
|
||||
System.out.println("remainder of a / b = " + remainder); // same sign as first operand
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue