CS100 J Spring 2004
Exercise 1
Due Monday 2/23 at 3pm


Exercise 1 deals with a simple loop. Complete Self Review Exercise for for-loops SR4 on page 74 of the text. The question asks you to write the loop--just the loop, not a method. For testing, however, you'll want to put the loop in a method in a class. We provide the skeleton class, E1, below. Submit the completed file E1.java on CMS. As always, follow the specifications, including the variable names to be used.

You do not need to give a written answer to the question asked in the text about what the sum converges to when n gets large. However, do experiment with large ns!

Note: If this was a test question, and it asks you to write a loop, then you write only the loop. You will assume that n is given and you do not write the method and class headers that we provide below for this exercise.

/** Sum the series 
 *    1/(1*1) + 1/(2*2) + ... + 1/(n*n)
 *  for n>=1
public class E1 {

  public static void main(String[] args) {

    int n= 3;  //Start small as you test your code.
               //Change n for experimentation.

    //Write your loop, the solution to SR4 on p.74 of the text, below