copyright Steve J. Hodges   http://steveh.net/cs20j/cs20j-hw01.html

# CS 20j Spring 2019

## Program One (Loan Payment Calculator)

Loan

### Program Description

Write a program ("Loan.java") to calculate the number of payments that must be made to repay a loan. The program should output your name, pengo account and email address all on the first line of output. The second line of output should list the due date or semester, and include the assignment title and number. Then, prompt the user for the amount to be borrowed, the annual interest rate, the number of payments to be made each year, and the amount of each payment (in that order, one prompt per line.) Then output the number of payments that must be made to repay the loan, formatted to exactly one decimal place, and the total to be reapid, to exactly two decimal places.

The equation for calculating the number of payments is:

where principal is the amount borrowed, interest is the interest rate per payment (not per year), payment is the amount of each payment, and log is the natural logarithm.

For example, if \$10,000 is borrowed at 12% annual interest rate, with monthly payment of \$263.34, we would do the following calculations:

which gives an answer of 48.0 payments to be made and a total of \$12,640.32 to be repaid (or \$12,640.22 is also correct.)

Your program should input from STDIN and send output to STDOUT. Your program must have at least one function (in addition to main) to calculate and return the number of loan payments.

### What to turn in

As usual, leave your .java file for this program ("Loan.java") in your home directory on pengo.

### Suggestions

You may wish to use the following program as a model. Note that this example is not necessarily properly formatted. Don't forget to follow the Program Guidelines in your submission!

```
// Calculates volume of a cylinder
import java.util.Scanner;

class CylinderApplication{

public static void main( String args[]){
Scanner cin = new Scanner(System.in);
System.out.println("Cylinder Voulume Calulator");
System.out.print("What is the cylinder height? ");
height = cin.nextDouble();
System.out.print("What is the cylinder radius? ");
System.out.print("A cylinder with height " + height+ " and ");
System.out.print("radius " + radius+ " has a volume of ");
}

public static double calcCylinderVolume( double height, double radius){
return height * Math.PI * radius * radius;
}

}
```