# CS 20j Fall 2018

## Program One (Loan Payment Calculator)

### Class Name

*Loan*

### Program Description

Write a program (named "Loan.java") to calculate a loan payment. The program should output on a line by itself, your name and email. The second line line should list the due date, 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 number of years the money is to be borrowed (in that order, one per line). Then, formatted to two decimal places, output the amount of each payment. 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 loan payment.

The equation for calculating the loan payment is:

where principal is the amount borrowed,
interest is the interest rate per payment,
and numPayments is the total number of payments that must be made.

For example, if $10,000 is borrowed at 12% annual interest rate,
to be repaid monthly for 4 years we would do the following calculations:

payment = $263.34

### 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[]){ double height=0.0, radius=0.0; 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? "); radius = cin.nextDouble(); System.out.print("A cylinder with height " + height+ " and "); System.out.print("radius " + radius+ " has a volume of "); System.out.printf("%.1f%n",calcCylinderVolume(height, radius)); } public static double calcCylinderVolume( double height, double radius){ return height * Math.PI * radius * radius; } }