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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started