Advertisement
Guest User

MortCalc

a guest
May 10th, 2011
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.21 KB | None | 0 0
  1. /**
  2. *
  3. * @author Damien Bell <SkyeShatter>
  4. */
  5. import java.text.NumberFormat;
  6. import java.util.Scanner;
  7. public class MortPayments {
  8. public static void main(String[] args){
  9. Scanner input = new Scanner(System.in);
  10. int i;
  11. double interest=0, loanPrinciple, time, rate;
  12. NumberFormat nf = NumberFormat.getInstance();
  13. nf.setMaximumFractionDigits(3);
  14. nf.setMinimumFractionDigits(2);
  15. System.out.println("Please enter the amount you wish to take out for a loan: ");
  16. loanPrinciple =input.nextDouble();
  17. System.out.println("Please enter the APR of the loan in % ( ex: 6.8 ) : ");
  18. rate= input.nextDouble();
  19. System.out.println("Please enter the term of the loan (in years): ");
  20. time= input.nextDouble();
  21. rate = rate/100;
  22.  
  23. for(i=0; i<time; i++){
  24. interest += loanPrinciple*rate;
  25. loanPrinciple *= (1+rate);
  26. }
  27. 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. ");
  28.  
  29. double monthPayment=0;
  30. monthPayment= time*12;
  31. monthPayment= loanPrinciple / monthPayment;
  32.  
  33. System.out.println("The monthly payment on your loan will be: "+ nf.format(monthPayment).toString());
  34.  
  35.  
  36. }// End main
  37. }// End Class
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement