Advertisement
Fakhru

Untitled

Aug 6th, 2014
234
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.13 KB | None | 0 0
  1. /*
  2. ___________ __ .__ .__
  3. \_ _____/____ | | _| |_________ __ ______________ _______|__|
  4. | __) \__ \ | |/ / | \_ __ \ | \_ __ \__ \ \___ / |
  5. | \ / __ \| <| Y \ | \/ | /| | \// __ \_/ /| |
  6. \___ / (____ /__|_ \___| /__| |____/ |__| (____ /_____ \__|
  7. \/ \/ \/ \/ \/ \/
  8.  
  9.  
  10. */
  11.  
  12. import java.util.Scanner;
  13. public class LoanCalc {
  14.  
  15.  
  16. private double loanAmount;
  17. private double rate;
  18. private int numberOfPayment;
  19.  
  20. public LoanCalc(){
  21. loanAmount = 0;
  22. rate = 0;
  23. numberOfPayment=0;
  24. }
  25.  
  26. public void setValue(){
  27. Scanner input = new Scanner(System.in);
  28. System.out.println("Insert Loan Amount: ");
  29. loanAmount = input.nextDouble();
  30. System.out.println("Insert Rates: ");
  31. rate = input.nextDouble();
  32. System.out.println("Insert Number Of Payment: ");
  33. numberOfPayment = input.nextInt();
  34. }
  35.  
  36. public double getLoanAmount(){
  37. return loanAmount ;
  38. }
  39.  
  40. public double getRate(){
  41. return rate;
  42. }
  43.  
  44. public double getPayment(){
  45. return numberOfPayment;
  46. }
  47.  
  48. public double getMonthly(){
  49. double monthly;
  50. monthly = (loanAmount+(numberOfPayment*((loanAmount *(rate/100)))))/(numberOfPayment * 12);
  51. return monthly;
  52. }
  53.  
  54. public double getTotalPayment(){
  55. double total;
  56. total = getMonthly() * (numberOfPayment * 12);
  57. return total;
  58. }
  59.  
  60.  
  61. }
  62.  
  63. class mainLoan{
  64. public static void main(String[] args){
  65. LoanCalc L1 = new LoanCalc();
  66. L1.setValue();
  67. System.out.println("Amount : "+L1.getLoanAmount());
  68. System.out.println("Rate : "+L1.getRate());
  69. System.out.println("Period : "+L1.getPayment());
  70. System.out.println("************************ : ");
  71. System.out.println("Monthly Payment : "+L1.getMonthly());
  72. System.out.println("Total Payment : "+L1.getTotalPayment());
  73. }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement