Question: java question a)Code a method that takes an array of integers as input and returns an array of integers as output. The value of cell

java question

a)Code a method that takes an array of integers as input and returns an array of integers as output. The value of cell i in the returned array is the sum of cell i and all the previous even numbers if cell i is even and is the sum of cell i and all the previous odd cells if cell i is odd.

Example

input: [1,2,3,4,5,6,7,8,9]

output: [1,2,4,6,9,12,16,20,25]

Note: no side effect should occur on the input array.

b)

Code a method called diffArList that:

  • Takes two array lists of Strings arL1 & arL2 as input
  • Returns a new array list contains all the values of arL1 that cannot be found in arL2.

Notes

  • you must not use any of these built-in methods: contains, lastIndexOf , indexOf.
  • Your code should be efficient (i.e. exist loop if it meets a condition) and should use the appropriate loop pattern

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!