Untitled

                Never    
C++
       
// Amortization Table
//Julieanna Prentice
//This program will......
//

# include <iostream>
# include <cmath>
# include <iomanip>
# include <fstream>
# include <string.h>
using namespace std;

int main()
{
	//DECLARATION OF VARIABLES//
	string   firstname;
	string   lastname;
	int      month = 0;
	int      num_payments = 0;
	char     answer = 'Y';
	double   loan = 0;
	double   term = 0;
	double   new_balance = 0;
	int      years = 0;
	double   rate = 0;
	double   moInterestRate = 0;
	double   payment = 0;
	double   balance = 0;
	double   monthPrinciple = 0;
	double   monthPaidInt = 0;
	double   moInterest = 0;
	double   principal = 0;


	//  I N P U T  //
	cout << " P R E N T I C E     B A N K " << endl;
	cout << " Hello! and Welcome to Prentice Bank's electronic" << endl;
	cout << " loan payment amortization calculator. Amortization" << endl;
	cout << " is paying off an amount owed over time by" << endl;
	cout << " making planned, incremental payments of" << endl;
	cout << " principal and interest. To amortize a loan" << endl;
	cout << " means to \'kill it off\'" << endl;

	while (answer == 'Y')
	{
		cout << "Would you like to create an Amortization table?" << endl;
		cout << "Enter 'Y' for Yes and 'q' to quit." << endl;
		cin >> answer;

		if (answer == 'Y' || answer == 'y')
		{
			cout << "Okay.. wel will first need some basic information about you and your loan. \n \n";
			cout << "What is your first and last name? ";
			cin >> firstname >> lastname;
			cout << "What is the full amount of your loan? " << endl;
			cin >> loan;
			cout << "What is the annual interest rate on your loan? (eg. .0415) " << endl;
			cin >> rate;
			cout << "How many years do you have to pay this loan off? " << endl;
			cin >> years;

			cout << "Loan Amount: " << loan << endl;
			cout << "Annual Interest rate: " << rate << endl;
			cout << "Years of Loan: " << years << endl;

			num_payments = years * 12;
			moInterestRate = rate / 12.0;

			if (rate == 0)
				payment = loan / num_payments;
			else
			{
				term = pow((1 + moInterestRate), num_payments);
				payment = (loan * moInterestRate * term) / (term - 1.0);
			}

			cout << fixed << showpoint << setprecision(2);
			cout << "Monthly payment:  $" << payment << endl;

			cout << endl;
			cout << setw(5) << "Month" << setw(10) << "Interest" << setw(10) << "Principal" << setw(9) << "Balance" << endl;
			cout << "-----------------------------------\n";

			balance = loan;

			for (month = 1; month <= num_payments; month++)
			{
				moInterest = moInterest * balance;
				if (month != num_payments)
					principal = payment - moInterest;
				else
				{
					principal = balance;
					payment = balance + moInterest;
				}

				balance -= principal;

				cout << setw(4) << month << setw(10) << moInterest << setw(10) << principal << setw(10) << balance << endl;
			}

			if (answer != 'Y')
			{
				cout << "Thanks you for visiting Prentice Bank's" << endl;
				cout << " electronic loan amortization calculator." << endl;
				cout << " Good luck in your New Home!" << endl;

			}
			else
			{
				cout << "Thank you for visiting Prentice Bank's " << endl;
				cout << " electrnic loan amortization calculator." << endl;
				cout << " Have a wonderful day and come visit us" << endl;
				cout << " again soon for all your banking needs." << endl;
			}

		}
	}

	return 0;
}

Raw Text