Question: - methods Write a Java program that contains a set of methods to fulfill the following requirement. One of the methods should be named as

- methods

Write a Java program that contains a set of methods to fulfill the following requirement. One of the methods should be named as wierdFilter(int[] arr). It takes an array of positive integers as an argument, and keeps only elements that satisfies at least one of the following conditions, and sets the other elements to -1.

1. Sum of digits of each number is an even number

2. Numbers whose leading digit equals the number of digits

for example, if the input array, arr = {58114, 10, 3430, 632, 4222},

then the result should be {58114, -1, 3430, -1, 4222},

because: 58114: meets the second condition

10: violates both conditions

3430: meets the first condition

632: violates both conditions

4222: meets both conditions

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