/**
 * This class can take a variable number of parameters on the command
 * line. Program execution begins with the main() method. The class
 * constructor is not invoked unless an object of type 'Class1'
 * created in the main() method.
 */
public class series
{
	protected double param = 0.0; 
	protected int n = 0;
	protected double term = 0.0;
	protected double val = 0.0;
	
	series(){
		param = 0.0;
		n = 0;
		term = 0.0;
		val = 0.0;
	}
	series(double x){
		param = x;
		n = 0;
		term = 0.0;
		val = 0.0;
	}
	
	public void first(){
		n = 0;
		term = 0.0;
		val = 0.0;
	}
	
	public void nextTerm(){
		n++;
		term = term + param;
		val = val + term;
	}
	
	public double valAt(int m){
		first();
		for (int i=0; i<m; i++)
			nextTerm();
		return val;
	}
	public void list(int m){
		first();
		for (int i=0; i<m; i++){
			System.out.print(term +", ");
			nextTerm();
		}
		System.out.println(" ");
		System.out.flush();
	}
	public static void pause(){
		System.out.print("Type return to contd:");
		System.out.flush();
		try {System.in.read();}
		catch (Exception e){}
	}
	
}	
	

