Write a program with a method that takes an argument of one int array. It should return a new int array with each value in the new array double that of the value in the old array.
import java.util.*;class Main { public static void main(String[] args) { int [] myarray = new int [5]; Scanner x = new Scanner(System.in); for (int i = 0; i < 5; i++){ myarray[i] = x.nextInt(); } System.out.println(Arrays.toString(multiplyby2(myarray))); } public static int [] multiplyby2 (int[] iarray) { int [] myarray2 = new int [iarray.length]; for (int a = 0; a < iarray.length; a++){ myarray2[a] = 2*iarray[a]; } return myarray2; }}
import java.util.*; class Main { public static void main(String[] args) { int [] myarray = new int [5]; Scanner x = new Scanner(System.in); for (int i = 0; i < 5; i++){ myarray[i] = x.nextInt(); } System.out.println(Arrays.toString(multiplyby2(myarray))); } public static int [] multiplyby2 (int[] iarray) { int [] myarray2 = new int [iarray.length]; for (int a = 0; a < iarray.length; a++){ myarray2[a] = 2*iarray[a]; } return myarray2; } }