How to add the numbers in the following series?

Code :

class series {
public static void main(String args[]){
int numerator, denominator;
numerator = 1;
denominator = 1;
System.out.print(numerator);
for(int counter=0;counter<=198;counter++){
denominator+=1;
if(denominator % 2 == 0){
System.out.print(" - ");
}else{
System.out.print(" + ");
}
System.out.print(numerator+"/"+denominator+" ");
}
}
}

The series in the program is 1 - 1/2 + 1/3 - 1/4 + 1/5 - 1/6... -1/200, how would you get the sum of the numbers?

Re: How to add the numbers in the following series?

Quote:

how would you get the sum of the numbers?

Use a loop and add the individual terms to a variable.

Continuation of http://www.javaprogrammingforums.com...igns-java.html