-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFinancialApplication.java
More file actions
37 lines (19 loc) · 877 Bytes
/
Copy pathFinancialApplication.java
File metadata and controls
37 lines (19 loc) · 877 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
29
30
31
32
33
34
35
36
37
import java.util.Scanner;
public class FinancialApplication{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
System.out.print("Enter loan amount: ");
double principalAmount = input.nextDouble();
System.out.print("Enter duration in years: ");
double years = input.nextDouble();
System.out.println("Interest interestRate\t\t Monthly Payment\t\tTotal Payment");
for(double interestRate = 5.0; interestRate <= 10.0; interestRate += 0.25){
double monthlyIntinterestRate = interestRate / 1200;
double noOfMonths = years * 12;
double monthlyPayment = (principalAmount * monthlyIntinterestRate) / (1 - Math.pow(1 + monthlyIntinterestRate, -noOfMonths));
double totalPayment = monthlyPayment * noOfMonths;
System.out.printf("%.2f \t\t ₦%.2f \t\t₦%.2f", interestRate, monthlyPayment, totalPayment);
System.out.println();
}
}
}