Quote:

/**

* A class for numeric progressions.

*/

public class Progression {

/** First value of the progression. */

protected long first;

/** Current value of the progression. */

protected long cur;

/** Default constructor. */

Progression() {

cur = first = 0;

}

/** Resets the progression to the first value.

*

* @return first value

*/

protected long firstValue() {

cur = first;

return cur;

}

/** Advances the progression to the next value.

*

* @return next value of the progression

*/

protected long nextValue() {

return ++cur; // default next value

}

/** Prints the first n values of the progression.

*

* @param n number of values to print

*/

public void printProgression(int n) {

System.out.print(firstValue());

for (int i = 2; i <= n; i++)

System.out.print(" " + nextValue());

System.out.println(); // ends the line

}

}

1. Implement a Java class (C2_2Progression) that extends the Progress class so that each value in the progression is the absolute value of the difference between the previous two values. You should include a default constructor that starts with 2 and 200 as the first two values and a parameteric constructor that starts with a specified pair of numbers as the first two values. You must name your class C2_2Progression .

2. Write a Java class (C2_3Progression.java) that extends the Progression class so that each value in the progression is the floor of the square root of the previous value. You are not allowed to use the Math.sqrt() method from the Java Math library. You should include a default constructor that has 65,536 as the first vlue and a parametric constructor that starts with a specified non-negative integer as the first value. You must name your class C2_3Progression .