In this lab, you will write an application that will read paired data from a text file and calculate the correlation coefficient. You will write a method to read the input and another method to calculate the correlation coefficient.
Display the correlation coefficient for paired data in a text file. Here is a sample run:
Name of the input file: PearsonRData.txt r = 0.8827
The data is read from an input file whose name is specified by the user. Each line in the file contains two double values. Both values correspond to the same subject in a statistical study. The first value is the value of the explanatory variable (x) and the second value is the value of the response variable (y). The exact number of lines in the file is not known ahead of time but you may assume that there will never be more than one hundred lines. Here is a sample file:
700 84.2 600 88.2 450 69.8 660 91.2 750 95.3
Your application should include a value-returning method whose purpose is to read the paired data into a two-dimensional array and return the number of data pairs found in the file.
Your application should include a value-returning method whose sole purpose is to calculate the correlation coefficient. The parameters to this method are a two-dimensional array containing the paired data and the number of data pairs in the two-dimensional array.
The file Hmwk15.java contains the main program and declarations for the other two methods. Your job is to write the code for these other two methods.
Submit your completed Hmwk15.java application as an attachment to an email message whose subject is "Hmwk15".