// Present Value of a Cash Flow Stream 

function PV(cashFlow, i){
	this.cashFlow = cashFlow;
	this.i = i;
}

// returns result
PV.prototype.result = function(){
	var npw = 0;
	for (var m = 0; m < this.cashFlow.length; m++){
		if (this.cashFlow[m] != 0) npw += this.cashFlow[m] / Math.pow((1 + this.i), m);
	}
	return npw;
}
// returns input values
PV.prototype.inputData = function(){
	return this.cashFlow + " " + this.i;
}

// Copyright engineeringtoolbox.com