 Back to our calculations. Now let's concentrate on the denominator. We're going to need the sum of the x deviations squared times the sum of the y deviations squared. Let's get our x sum of squares, which will be 1 squared plus negative 1 squared plus negative 2 squared plus 2 squared. Then we'll have our y sum of squares, and that's going to be 16 plus 9, negative 3 times negative 3, plus 64 plus 81, which is negative 9 squared. That comes out to 170. Again, we've done the same set of operations twice, so this is a great candidate for a method. We'll call it sum of squares that takes an array of double and returns the sum of the squared elements. Returns a double, call it sum of squares, and it'll take an array, which we'll call data. We'll set a total to 0, and then loop through data, squaring each element and adding it to the total, and then we'll return the total. Let's complete our calculation of the denominator. We'll take the x sum of squares times the y sum of squares and take the square root of that whole thing. That's the square root of 10 times 170, which is 41.23, and our correlation coefficient will be the numerator, and this time I'm going to use the spreadsheet's capabilities. This cell divided by that cell, and there's our correlation coefficient. By the way, we can check our work by having the spreadsheet do the calculation as well. We'll ask for the correlation of the values in B4 through E4 with B5 through E5. And yes, we did our calculations by hand correctly. Now we can come back to our pseudo-code and complete it. We'll have our x sum of squares, which will be sum of squares of x and our y sum of squares, which is going to be the sum of squares of the y-array. Then the denominator is the square root of x sum of squares times y sum of squares. Our correlation coefficient is the numerator divided by the denominator. I have too many slashes there. And we'll return R. Time to move on to the main method, where we'll start by reading in the two arrays. The assignment tells you to implement a method named ReadArray to read them in, and we won't discuss it in this video, but let's take note of it. We'll have to implement ReadArray, which takes a scanner and a number of items as its parameters and returns an array of double. That means we have to prompt for and read the number of items the person wants in each of their arrays, and then we'll make our calls. We'll have our x array, which will be the result of saying ReadArray with our input and the number of items, which I'm going to call an items for lack of a better name. Our y array will be ReadArray input and items. And I'll probably want to prompt here, by the way. So I might want to start out by saying system.out.printLine of enter first array and enter second array. And now that I have those, I can say that our correlation will get correlation of x and y and then print the correlation properly labeled. And there's the pseudocode. The important thing to remember from this video is that we solved the problem by hand and analyzed what we were doing and then wrote those observations as our pseudocode. And we weren't afraid of making lots of methods to break the problem into smaller sub-tasks for getting the deviations and the sum of squares.