Use Java Write Method Takes Integer Array Parameter Replaces Odd Number Array S Value Time Q37076321

use java

Write a method that takes an integer array parameter andreplaces each odd number in the array with it’s value times 2.

public void doubleOdd(int [] arr);

So this method would change {3,4,5,8,9} into {6,4,10,8,18}

Write a main method to test the above method.

Write a method that returns the difference between the largestand smallest item in an integer array

static int maxDiff(int [] arr)

Write a main method to test the above method.


Solution


import java.util.Arrays;//Main.javapublic class Main { public static void doubleOdd(int [] arr){ for(int i = 0;i<arr.length;i++){ if(arr[i]%2==1){

OR
OR

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.