Question: { 1 2 4 } J a v a this problem tor tull credit. Late submissions lose 2 points per day. Write a method named

{124}Java
this problem tor tull credit. Late submissions lose 2 points per day.
Write a method named ar rayAllMultiples that, given an array of int values greater than 0,
returns whether the values are all integer multiples of one of the values in the array, which we'll
call the base. For example, given the array {4,2,8} you would return true, since 4 and 8
are integer multiples of the base 2. Given the array {2,2,5} you would return false, since
there is no value that all others are integer multiples of.(If the array contains 1, you should
always return true, but there's no need to handle this case specifically.)
You should approach this problem in two steps. First, identify the base-the value in the array
that you are going to check whether others are multiples of. This may sound complicated, but
it's straightforward. You do not need to and should not check whether every value is the base!
Your solution should not contain a nested loop.
Next, check all the values in the array and look for a counterexample-a value that is not a
multiple of the base.
The passed array may be null or empty. In those cases you should return false. Valid arrays
will contain only integers strictly greater than 0.
(i) For this problem we're expecting only a method. IN JAVA
{ 1 2 4 } J a v a this problem tor tull credit.

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 Programming Questions!