-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmortgage.java
More file actions
29 lines (21 loc) · 975 Bytes
/
mortgage.java
File metadata and controls
29 lines (21 loc) · 975 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
import java.util.Scanner;
import java.text.NumberFormat;
class Mortgage{
public static void main(String[] args){
final byte months_in_year = 12;
final byte percent = 100;
Scanner userInput = new Scanner(System.in);
System.out.print("Principle: ");
int principleInput = userInput.nextInt();
System.out.print("Annual Interest Rate: ");
float annualInterest = userInput.nextFloat();
float monthlyInterest = annualInterest /percent/months_in_year;
System.out.print("Period (Years): ");
byte mortgageInput = userInput.nextByte();
int numberOfPayments = years * months_in_year;
double mortgage = principle * (monthlyInterest * Math.pow(1 + monthlyInterest, numberOfPayments)/ (math.pow(1 + monthlyInterest, numberOfPayments)-1));
String mortgageFormatted = NumberFormat.getCurrencyInstance();
System.out.println("Mortage: " + mortgageFormatted);
Math.pow(rate, mortgageInput);
}
}