3. (5 pts) Write code for a Java method that takes in as input parameter an integer number, say num, and returns a double array of size num with all entries in the array initialized to 3.0.
public static double[] arrayInit (int num){ // You have to declare and create a result array to be returned
} //end arrayInit
4. (6 pts) Write code for a Java method that takes in two int arrays of the same size as input parameters, multiplies the corresponding entries, and returns the resulting int array. public static int[] product (int[] array1, int[] array2){ // You have to declare and create a result array to be returned
} // end product
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num;
System.out.print("Enter num:
");
num=sc.nextInt();
double
result[]=arrayInit(num);
for(int i=0;i<2*num;i++)
System.out.print(result[i]+"
");
}
public static double[] arrayInit (int num){
double r[] =new double[2*num];
for(int i=0;i<2*num;i++)
r[i]=3.0;
return r;
}
}
import java.util.*;
public class Main
{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
System.out.print("Enter size of
array: ");
n=sc.nextInt();
int a[]=new int[n];
int b[]=new int[n];
System.out.print("Enter value in array1: ");
for(int i=0;i<n;i++)
a[i]=sc.nextInt();
System.out.print("Enter value in array2: ");
for(int i=0;i<n;i++)
b[i]=sc.nextInt();
int c[]=product (a, b);
for(int i=0;i<n;i++)
System.out.print(c[i]+" ");
}
public static int[] product (int[] array1, int[] array2){
int result[] = new int[array1.length];
for(int i=0;i<array1.length;i++)
result[i]=array1[i]*array2[i];
return result;
}
}
3. (5 pts) Write code for a Java method that takes in as input parameter an...