A standard XY graph is used to depict a collection of data points, where each point consists of two components: This can be used to examine relationships between two phenomena in everyday life. For example, if you wanted to examine the relationship between years of education and annual income, you might collect data from many different people, each of whom would provide you with a data point, where the X value is "years of education" and the Y value is "annual income". Once you collected enough data points -- perhaps in the hundreds or lower thousands -- you can then use the data to examine the relationship between the two in various ways, such as the following: All of these things would be part of your process of analyzing the data, drawing various conclusions, and arguing for those conclusions. These are things you might find yourself doing with data in various fields, such as business or the social sciences. Even if you do not have to carry out these tasks in your own careers, it is worthwhile to have a general idea of how they work.

For the purposes of this homework assignment, you will be given a smaller data set (40 data points), where the X values are all held in one array, while the Y values are all held in another array. The "pairness" of the X and Y values is maintained via corresponding array indices. In other words, the first data point (85, 94) will have its X and Y values and index 0 of the respective arrays, the second data point (99, 82) at index 1, and so forth. As is likely obvious, the arrays will have the same length. You will be expected to calculate and announce three statistics for this small data set: See program output to get an idea of what should print out when your program runs.
public class DataStatistics {
  
   public static void main (String[] args) {
    
      // Data source: http://www.math.hope.edu/swanson/data/tests2.txt

      long[] xValues = { 85, 99, 99, 81, 69, 84, 79, 94, 
                        85, 64, 69, 67, 53, 71, 70, 74, 
                        89, 77, 90, 83, 92, 89, 70, 78, 
                        96, 99, 77, 85, 57, 74, 94, 81, 
                        53, 60, 73, 87, 82, 44, 82, 54 };
      
      long[] yValues = { 94, 82, 95, 79, 90, 93, 81, 95, 
                        91, 89, 92, 89, 82, 87, 42, 68, 
                        84, 84, 95, 69, 84, 82, 70, 88, 
                        69, 81, 98, 82, 59, 85, 97, 79, 
                        69, 91, 62, 91, 98, 81, 99, 98 };

      // Normally, it would not be necessary to create a
      // new variable for holding array length because 
      // you could simply use the ".length" expression.
      // Here, however, it makes sense to do so because 
      // both arrays have the same length and we will 
      // be using that value in our calculations.
      long len = xValues.length;
      
      
      // The code below can be uncommented for testing, 
      // though it should not be in the final version 
      // of the program:
      
      /* 
      for (int i = 0; i < xValues.length; i++)
        System.out.printf("DP #%2d: X = %d, Y = %d%n", i+1, xValues[i], yValues[i]);
      */
      
      // YOUR CODE GOES HERE
      // If you declare anymore numeric variables, let
      // them all be of the long type. This does not 
      // apply to for-loop variables, which should still 
      // be of type int









      
   }
  
}

Program Output:

Sum(X)      = 3109
Sum(Y^2)    = 285494
[Sum(X)]^2  = 9665881
       
Questions:
  1. How did the process of creating these programs go for you?
  2. What were your main challenges and how did you overcome them?
  3. What did you learn that may be of use as you move along in this class?