Hello,
have to write a program to calculate the monthly, balance and interest paid on a balloon mortgage.
The program must use a for loop to process the payments, and the results must display in a table with the final (balloon) payment showing on the last line.
Output should look like this:
Please enter your mortgage amount: 100000
Please enter your APR: 5
Please enter your payment amount: 1000
Please enter the number of years of your loan: 5
Month Balance Payment Interest
1 100000.00 1000.00 412.50
2 99412.50 1000.00 410.05
loops...to month 60
Balloon Payment: 60046.43
I need it to display the updated calculations until the final payment is reached. Also the table is indented for some reason. Any help about how to get this functional would be greatly appreciated.
Here is what I have thus far:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37
|
#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double mortAmount, payment, apr, years, months;
int paymentCounter;
cout << "Please enter your mortgage amount: ";
cin >> mortAmount; //gets mortgrage amount from user.
cout << "Please enter your APR: ";
cin >> apr; //gets annual interest rate from user.
apr = (apr/100); // converts apr rate to decimal.
double mApr = apr/12; //converts apr to monthy apr
cout << "Please enter your payment amount: ";
cin >> payment; //gets payment amountt from user.
cout << "Please enter number of years of your mortgage: ";
cin >> years; // gets number of years from the user.
double intPaid = (mortAmount - payment) * apr/12; // calculates interest paid on mortgage.
double mortBalance = (mortAmount - payment) + intPaid; // calculates remaining mortgage balance.
int numPayments = years * 12;
cout << setiosflags(ios::fixed | ios::showpoint) << setprecision(2); //formats output with decimal two places.
cout << setw(8) << "Month" << setw(9) << "Balance" << setw(10) << "Payment" << setw(11) << "Interest" << "\n";
for (paymentCounter = 1; paymentCounter <= numPayments; paymentCounter++) // loop counts the number of months
//table output begins
cout << setw(8) << paymentCounter << setw(9) << mortBalance << setw(10) << payment << setw(11) << intPaid <<"\n";
}
|