hey there. This is Erinn Hansen and I have a quick question about this assignment I am working on. I pretty much have it, except for it's a little backwards. This assignment is:
Write a program which accepts the following user input:
priceOfHouse, numMonths
Print an amortization chart as shown below.
Price: 100000.00
Month Balance Payment
100 99000 1000.00
...
2 1000.00 1000.00
1 0 1000.00
Here is my code that I have:
#include
#include
using namespace std;
int main()
{
double priceOfHouse, numMonths, payment = 0;
double balance;
cout << "Price: "; cin >> priceOfHouse;
cout << "Number of months: "; cin >> numMonths;
balance = priceOfHouse;
payment = priceOfHouse / numMonths - payment;
cout << "Month \t Balance \t Payment " << endl; do { balance = balance - payment; cout << numMonths << "\t" << Balance << "\t" << Payment << endl; numMonths--; } while ((balance > 0) && (numMonths <= 100))
}
Instead of getting:
Price: 100000.00
Number of months: 100
Month Balance Payment
1 100000.00 1000.00
2 99000.00 1000.00
...
100 1000.00 1000.00
I get:
Price: 100000.00
Number of months: 100
Month Balance Payment
100 99000 1000.00
...
2 1000.00 1000.00
1 0 1000.00
Basically it's backwards and want to know how to make it so that it is like this:
Month Balance Payment
1 100000.00 1000.00
2 99000.00 1000.00
...
100 1000.00 1000.00
I know it's probably something simple, but can't seem to figure out what is wrong. Could someone help me :) . thanks.