Complete the code to add two numbers and print the result.
int a = 5; int b = 3; int sum = a [1] b; System.out.println(sum);
The + operator adds two numbers together.
Complete the code to multiply two numbers and print the result.
int x = 4; int y = 7; int product = x [1] y; System.out.println(product);
The * operator multiplies two numbers.
Fix the error in the code to correctly divide two numbers and print the result.
int numerator = 10; int denominator = 2; int result = numerator [1] denominator; System.out.println(result);
The / operator divides the numerator by the denominator.
Fill both blanks to calculate the remainder of division and print it.
int dividend = 17; int divisor = 5; int remainder = dividend [1] divisor; System.out.println(remainder [2] 2);
The % operator gives the remainder of division. The + operator adds 2 to the remainder.
Fill all three blanks to create a map of numbers to their squares for numbers greater than 3.
Map<Integer, Integer> squares = new HashMap<>(); for (int num = 1; num <= 5; num++) { if (num [1] 3) { squares.put(num, num [2] num); } } System.out.println(squares[3]);
The operator > checks if the number is greater than 3. The * operator squares the number. The .toString() method converts the map to a string for printing.
