Question: I would like to solve the follwoing question in Java please, An array is called complete if it contains an even element, a perfect square
I would like to solve the follwoing question in Java please,
An array is called complete if it contains an even element, a perfect square and two different elements that sum to 8. For example, {3, 2, 9, 5} is complete because 2 is even, 9 is a perfect square and a[0] + a[3]= 8. Write a function named isComplete that accepts an integer array and returns 1 if it is a complete array, otherwise it returns 0. Your method must be fficient. it must return as soon as it is known that the array is complete.
Example if the input array is {36, -28}, it returns 1, reason: 36 is even, 36 is a perfect square, 36-28 = 8 if the input array is {36, 28}, it returns 0, reason: There are no two elements that sum to 8 if the input array is {4}, it returns 0, reason: It does not have two different elements that sum to 8 (you can't use a[0]+a[0]) if the input array is {3, 2, 1, 1, 5, 6}, it returns 0, reason: there is no perfect square. If the input array is {3, 7, 23, 13, 107, -99, 97, 81}, it returns 0, reason: there is no even number.
public static int isComplete(int[ ] a){ }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
