Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. double calculate_monthly_payment(double R, double N, double L)
  8. {
  9. return L * ((R * pow((1.0 + R), N)) / (pow((1 + R), N) - 1.0));
  10. }
  11.  
  12. int main()
  13. {
  14. string sirname;
  15. string lastname;
  16. double num_of_payments;
  17. double num_of_years;
  18. double loan_amount;
  19. double monthly_rate;
  20. double annual_rate;
  21. double monthly_payment;
  22. double amount_paid;
  23. double interest_amount;
  24. double equationTop;
  25. double exp;
  26.  
  27.  
  28. cout << "What is your name? (format: Mr. Smith): ";
  29. cin >> sirname >> lastname;
  30.  
  31. cout << sirname << lastname << ", what is the amount of your loan? (format: 2450) ";
  32. cin >> loan_amount;
  33. cout << "What is the annual interest rate of your loan? (format: 3.0) ";
  34. cin >> annual_rate;
  35. cout << "How many years do you have to pay this loan? (format: 5) ";
  36. cin >> num_of_years;
  37.  
  38. monthly_rate = (annual_rate / 100) / 12;
  39. cout << "The monthly is" << monthly_rate << endl;
  40.  
  41. num_of_payments = num_of_years * 12;
  42. cout << "The number of payments is " << num_of_payments << endl;
  43.  
  44. exp = pow((1 + monthly_rate), num_of_payments);
  45.  
  46. double L, R, N;
  47.  
  48. L = loan_amount;
  49. R = monthly_rate;
  50. N = num_of_payments;
  51.  
  52. monthly_payment = L * ((R * pow((1.0 + R), N)) / (pow((1 + R), N) - 1.0));
  53.  
  54. cout << "The monthly payment" << monthly_payment;
  55.  
  56. cout << endl << endl << endl << endl;
  57. cout << "Name: " << lastname << ", " << sirname << endl;
  58. cout << "Loan Amount: " << "$" << loan_amount << endl;
  59.  
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement