## com.croftsoft.core.math Class FinanceLib

```java.lang.Object com.croftsoft.core.math.FinanceLib
```

`public final class FinanceLibextends Object`

Financial calculations.

Since:
1999-08-15
Version:
2001-10-10
Author:
David Wallace Croft

Method Summary
`static double` ```annualSavingsNeeded(double f, double r, double t)```
Calculates the annual savings necessary to accumulate a specified value in the future.
`static double` ```futureValue(double c, double r, double t)```
The future value of a cash flow received today.
`static double` ```futureValueAnnuity(double c, double r, double t)```
Calculates the future value of an annuity.
`static double` ```internalRateOfReturn(double irrEstimate, double[] cashFlows)```
The calculated discount rate where the net present value is 0.
`static double` ```netPresentValue(double discountRate, double[] cashFlows)```
The discounted value of multiple cash flows received in the future.
`static double` ```presentValue(double[] c, double r)```
The discounted value of varying annual cash flows.
`static double` ```presentValue(double c, double r, double t)```
The discounted value of a single cash flow received in the future.
`static double` ```presentValueAnnuity(double c, double r, double t)```
Calculates the present value of an annuity.
`static void` ```testAnnuity(double C, double r, double T)```
Test method.
`static void` ```testRetire(double desiredSavingsInterestIncome, double savingsInterestRate, double inflationRate, double taxRate, double investmentInterestRate, double yearsOfSaving)```

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Method Detail

### testRetire

```public static final void testRetire(double desiredSavingsInterestIncome,
double savingsInterestRate,
double inflationRate,
double taxRate,
double investmentInterestRate,
double yearsOfSaving)```

### testAnnuity

```public static final void testAnnuity(double C,
double r,
double T)```
Test method. Prints the future value of an annuity followed by the present value calculated three different ways.

Parameters:
`c` - Annual cash income starting one year from today.
`r` - Annual interest earned on income.
`t` - Number of years of cash income.

### futureValue

```public static final double futureValue(double c,
double r,
double t)```
The future value of a cash flow received today.

Parameters:
`c` - Cash flow today.
`r` - Inflation rate.
`t` - Number of years from today when the value is evaluated.

### futureValueAnnuity

```public static final double futureValueAnnuity(double c,
double r,
double t)```
Calculates the future value of an annuity.

Parameters:
`c` - Annual cash income starting one year from today.
`r` - Annual interest earned on income.
`t` - Number of years of cash income.

### internalRateOfReturn

```public static final double internalRateOfReturn(double irrEstimate,
double[] cashFlows)```
The calculated discount rate where the net present value is 0.

Parameters:
`irrEstimate` - The initial estimated value for the IRR (e.g., 0.10 for 10%).
`cashFlows` - Array of cash flows received in the future, indexed from time = 0.

### netPresentValue

```public static final double netPresentValue(double discountRate,
double[] cashFlows)```
The discounted value of multiple cash flows received in the future.

Parameters:
`discountRate` - The discount rate or cost of capital (e.g., 0.10 for 10%).
`cashFlows` - Array of cash flows received in the future, indexed from time = 0.

### presentValue

```public static final double presentValue(double c,
double r,
double t)```
The discounted value of a single cash flow received in the future.

Parameters:
`c` - Cash flow received in the future
`r` - Inflation or annual interest.
`t` - Number of years from today when the cash flow is received.

### presentValue

```public static final double presentValue(double[] c,
double r)```
The discounted value of varying annual cash flows.

Parameters:
`c` - Array of annual cash income starting one year from today.
`r` - Annual interest earned on income.

### presentValueAnnuity

```public static final double presentValueAnnuity(double c,
double r,
double t)```
Calculates the present value of an annuity.

Parameters:
`c` - Annual cash income starting one year from today.
`r` - Inflation or annual interest.
`t` - Number of years of cash income.

### annualSavingsNeeded

```public static final double annualSavingsNeeded(double f,
double r,
double t)```
Calculates the annual savings necessary to accumulate a specified value in the future.

Parameters:
`f` - Future value desired.
`r` - Annual interest.
`t` - Number of years of savings.