Advertisement
Guest User

Untitled

a guest
Oct 1st, 2014
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.01 KB | None | 0 0
  1. int main()
  2. {
  3. string sirname;
  4. string lastname;
  5. double num_of_payments;
  6. double num_of_years;
  7. double loan_amount;
  8. double monthly_rate;
  9. double annual_rate;
  10. double monthly_payment;
  11. double amount_paid;
  12. double interest_amount;
  13.  
  14.  
  15. cout << "What is your name? (format: Mr. Smith): ";
  16. cin >> sirname >> lastname;
  17.  
  18. cout << sirname << lastname << ", what is the amount of your loan? (format: 2450) ";
  19. cin >> loan_amount;
  20. cout << "What is the annual interest rate of your loan? (format: 3.0) ";
  21. cin >> annual_rate;
  22. cout << "How many years do you have to pay this loan? (format: 5) ";
  23. cin >> num_of_years;
  24.  
  25. cout << "The loan amount is " << loan_amount << endl;
  26.  
  27. annual_rate = annual_rate / 12;
  28. cout << "The annual rate is" << annual_rate << endl;
  29.  
  30. num_of_payments = num_of_years * 12;
  31. cout << "The number of payments is " << num_of_payments << endl;
  32.  
  33. monthly_payment = loan_amount * ((annual_rate * pow(1.0 + annual_rate, num_of_payments)) / ((pow(1.0 + annual_rate, num_of_payments) - 1));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement