Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

Students also viewed these Databases questions