Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * @author Damien Bell <SkyeShatter>
- */
- import java.text.NumberFormat;
- import java.util.Scanner;
- public class MortPayments {
- public static void main(String[] args){
- Scanner input = new Scanner(System.in);
- int i;
- double interest=0, loanPrinciple, time, rate;
- NumberFormat nf = NumberFormat.getInstance();
- nf.setMaximumFractionDigits(3);
- nf.setMinimumFractionDigits(2);
- System.out.println("Please enter the amount you wish to take out for a loan: ");
- loanPrinciple =input.nextDouble();
- System.out.println("Please enter the APR of the loan in % ( ex: 6.8 ) : ");
- rate= input.nextDouble();
- System.out.println("Please enter the term of the loan (in years): ");
- time= input.nextDouble();
- rate = rate/100;
- for(i=0; i<time; i++){
- interest += loanPrinciple*rate;
- loanPrinciple *= (1+rate);
- }
- System.out.println("The total amount to repay your loan will be: " +nf.format(loanPrinciple).toString() + " . "+nf.format(interest).toString()+ " of that amount is just interest. ");
- double monthPayment=0;
- monthPayment= time*12;
- monthPayment= loanPrinciple / monthPayment;
- System.out.println("The monthly payment on your loan will be: "+ nf.format(monthPayment).toString());
- }// End main
- }// End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement