325H1) Could you please help me to solve this problem? Write the following ML fu
ID: 3931864 • Letter: 3
Question
325H1) Could you please help me to solve this problem?
Write the following ML function:
Write a function which takes two integer list parameters and if they are of equal size, finds the product of all elements in both lists. Otherwise, the function should return 0.
Note: Write only one function.
Sample Run:
- mult([4,8,2],[1,2,5]); //Product of 4,8,2,1,2,5 is 640
val it = 640 : int
- mult([4,8],[1,2,5]); //different lengths
val it = 0 : int
- mult([4,8,2,9],[1,2,5]); //different lengths
val it = 0 : int
Explanation / Answer
public class multiply()
{
public static void multiplynumbers(int []x,int[]y)
{
product=1;
if(x.length==y.length)
{
for (int i=0;i<=x.length;i++)
{
}
return product;
else
return 0;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.