‫Hello my friends, and welcome to coding Exercise number six.
‫In this exercise, we are asked to write a program to multiply corresponding elements of two arrays
‫of integers.
‫For example, if we have two arrays, the first one contain contains one three minus five four, and
‫the second array contains one four minus five minus two.
‫These are the elements, the multiplication.
‫The corresponding multiplication of the elements of the two arrays will give us one 1225 minus eight.
‫So we multiply the first element with the first element of the second array.
‫We multiply the second element of the first array with the second element of the second array and so
‫on.
‫Post the video and think about how to solve such a problem and such an exercise.
‫I want from you to upload and write in the comments your solution weighting your solutions.
‫I hope you solve the problem correctly.
‫Now let's implement the solution.
‫First of all, let's start by int array.
‫I will make it without entering.
‫The user will enter the input of this array.
‫I will make it simple in order to understand the concept of multiplication of arrays, not the accessing
‫and inserting elements of that arrays.
‫I will name it left array for array number one equal to open curly braces, three minus five and four.
‫I took these elements.
‫Because as we see them, as we saw them in the the presentation and the beginning of this exercise,
‫we have the we have the result of these to our multiplication of the stories.
‫And I will took also one for minus five and two minus two.
‫Now let's start this describing for the user what to what will happen.
‫I will not print them directly.
‫I will not, because we don't.
‫We have them here.
‫Okay, so I will start by the for loop without.
‫I was trying to print them.
‫Before multiplication, but no need because we have already seen them here.
‫One three minus five, 414 minus five minus two.
‫So four int i when dealing with our arrays, think about using 99% of our loops and the loops.
‫Array number one dot length and a plus plus, since they are the same length.
‫No need to check for the other oc and num one equal to array one at index I.
‫I'm getting every element.
‫So if we are in the first iteration number at index zero will be number one of array one, which is
‫one and I'm getting and num two equal array at index two.
‫Sorry, array of array to add an index.
‫So the first iteration I'm getting array one index zero array to index zero one times one.
‫It will give me one.
‫So I multiply multiplying here.
‫I need to make a string to create a string result equal to
‫this and I will append this string by the results.
‫So result plus equal.
‫Remember this operator.
‫Integer.
‫I'm using integer to string.
‫Num one times num two.
‫Plus.
‫The space.
‫We can make like this.
‫So system that out dot print l n the result
‫plus result.
‫Let me run and see.
‫I were run with coverage.
‫And here we go.
‫This is the result.
‫One times 113 times four, 12 minus five times minus five.
‫25, four times minus two is minus eight.
‫So we succeeded in making this this exercise.
‫You can use the integer class to string, but no need, because here we understand that number one times
‫number two integer times integer will give an integer and the result will be this integer.
‫The result would be added to the string as a string.
‫So Java will transform this multiplication to strings.
‫So congratulations, guys.
‫We have succeeded in solving this exercise.