Question: in java Question #1: calculate Even Sum (50 points): Please fill the function int calEvenSum (int n) to calculate the sum of all even numbers

in java

Question #1: calculate Even Sum (50 points): Please fill the function int calEvenSum (int n) to calculate the sum of all even numbers between 1 and n (including). ( Hint: Even number is evenly divisible by two.)

For example,

Input: n = 4 Return: 6 (Because 2 + 4 = 6) n = 3 Return: 2

Question #2: checkMagicSquare (50 points): Please write the function boolean checkMagicSquare (int [][]) is to check if the given square matrix is a magic square. (Note: For a square matrix, if the sum of all the elements on main diagonal and the sum of all elements on anti-diagonal are the same, this matrix is defined as a magic square.)

For example

Input: arr = {1, 4

2, 6}

Return: False (Because 1 + 6 2 + 4)

Input: arr = {1, 4, 4

2, 1, 5 3, 5, 6}

Return: True (Because 1 + 1 + 6 = 4 + 1 + 3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!