@@ -0,0 +1,2134 @@
+/* Name:       Dan Wilder%0A * Class:      CMP SCI 2261 - E01%0A * Due Date:   22 September 2014%0A */%0A%0Apublic class PrimeNumberList %7B%0A%09%0A  /* This class uses the Sieve of Eratosthenes algorithm for %0A   * for generating all prime numbers up to a given limit then%0A   * stores the result in an array to be accessed by the user.%0A   */%0A%09%09%09 %0A  private int%5B%5D data;    // Storage for prime numbers%0A  %0A/*****************************************************************************/%0A  %0A  public PrimeNumberList() %7B%0A%09  %0A    // Default constructor -%3E Stores only the first prime number, 2%0A%09%09%09  %0A    data = new int%5B1%5D;%0A    data%5B0%5D = 2;%0A  %7D%0A  %0A/*****************************************************************************/%0A%09%09  %0A  public PrimeNumberList(int upperLimit) %7B%0A%09%09  %0A    boolean%5B%5D isComposite = new boolean%5BupperLimit + 1%5D;%0A%09  /* Array to keep track of which numbers are composite. %0A%09   * The boolean value at an index represents whether the%0A%09   * numerical value of that index is composite. %0A%09   * Default initialization sets all to false. %0A%09   */%0A%09%09%09  %0A    // Sieve of Eratosthenes: --%3E Identify composite numbers%0A%09for (int p = 2; p*p %3C= upperLimit; p++) %7B%0A      if (isComposite%5Bp%5D == false) %7B%0A    %09%0A%09    // If p is prime, mark multiples of it as composite%0A%09%09for (int multiple = p; p*multiple %3C= upperLimit; multiple++) %7B%0A%09%09  isComposite%5Bp*multiple%5D = true;%0A%09%09%7D%0A      %7D%0A    %7D%0A%09%0A    // Count the primes%0A%09int numPrime = 0;%0A    for (int i = 2; i %3C= upperLimit; i++) %7B%0A      if (isComposite%5Bi%5D == false)%0A        numPrime++;%0A%09%7D %0A%09%09    %0A%09// Create and store the primes into member attribute 'data'%0A%09data = new int%5BnumPrime%5D;%0A%09int index = 0;%0A%09for (int i = 2; i %3C= upperLimit; i++) %7B%0A%09  if (isComposite%5Bi%5D == false) %7B%0A%09    data%5Bindex%5D = i;%0A%09    index++;%0A%09  %7D%0A%09%7D%0A%09%09    %0A  %7D %0A  %0A/*****************************************************************************/%09 %0A  %0A  public int length() %7B%0A    return data.length;%0A  %7D%0A  %0A/*****************************************************************************/ %0A  %0A  public int getValue(int index) %7B%0A    return data%5Bindex%5D;%0A  %7D%0A  %0A/*****************************************************************************/%0A%0A%7D%0A

Add PrimeNumberList.java