in java Question #1: calculate Even Sum (50 points): Please fill the function in
ID: 3797387 • Letter: I
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 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)
Explanation / Answer
1.
int calEvenSum(int no)
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.