Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <string>
- using namespace std;
- double calculate_monthly_payment(double R, double N, double L)
- {
- return L * ((R * pow((1.0 + R), N)) / (pow((1 + R), N) - 1.0));
- }
- int main()
- {
- string sirname;
- string lastname;
- double num_of_payments;
- double num_of_years;
- double loan_amount;
- double monthly_rate;
- double annual_rate;
- double monthly_payment;
- double amount_paid;
- double interest_amount;
- double equationTop;
- double exp;
- cout << "What is your name? (format: Mr. Smith): ";
- cin >> sirname >> lastname;
- cout << sirname << lastname << ", what is the amount of your loan? (format: 2450) ";
- cin >> loan_amount;
- cout << "What is the annual interest rate of your loan? (format: 3.0) ";
- cin >> annual_rate;
- cout << "How many years do you have to pay this loan? (format: 5) ";
- cin >> num_of_years;
- monthly_rate = (annual_rate / 100) / 12;
- cout << "The monthly is" << monthly_rate << endl;
- num_of_payments = num_of_years * 12;
- cout << "The number of payments is " << num_of_payments << endl;
- exp = pow((1 + monthly_rate), num_of_payments);
- double L, R, N;
- L = loan_amount;
- R = monthly_rate;
- N = num_of_payments;
- monthly_payment = L * ((R * pow((1.0 + R), N)) / (pow((1 + R), N) - 1.0));
- cout << "The monthly payment" << monthly_payment;
- cout << endl << endl << endl << endl;
- cout << "Name: " << lastname << ", " << sirname << endl;
- cout << "Loan Amount: " << "$" << loan_amount << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement