-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLoanAmount.java
More file actions
32 lines (19 loc) · 807 Bytes
/
LoanAmount.java
File metadata and controls
32 lines (19 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// calculation of loan amount over the years ;
import java.util.Scanner;
public class LoanAmount {
public static void main(String[] args ) {
Scanner input = new Scanner(System.in) ;
System.out.print("Enter annual interest rate " );
double annualrate = input.nextDouble();
System.out.print("Enter number of years" );
double numberofyears = input.nextDouble();
System.out.print("Enter loan amount " );
double loanamount = input.nextDouble();
double monthlyinterestrate = annualrate / 1200 ;
double monthlypayment = loanamount * monthlyinterestrate / (1
- 1 / Math.pow (1+monthlyinterestrate , numberofyears * 12)) ;
double totalpayment = monthlypayment * numberofyears * 12 ;
System.out.println(" monthly payment " + monthlypayment );
System.out.println(" total payment " + totalpayment );
}
}