Problems with loop

I'm trying to get this to output:
Month   Principal($)  Interest($)  Tax($)   Payment($)  New Principal($)
1       20,000.00     100.00       58.33    700.00      19,458.33
2       19,141.70     100.00       58.33    700.00      18,915.56

and so on that the new principal is $0
I'm an extreme beginner and I thought I had a good foundation but apprently I need much help. Here is what I have so 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
#include <iostream>                     // <<, >>, cout, cin
#include <cmath>
#include <iomanip>

using namespace std;                    //Standard library

int main()                              //Program start
{
    int m;
    float p, i=100.00, t=58.33, y=700.00, n;
    string Table;
    Table = "Month   Principal($)  Interest($)  Tax($)   Payment($)  New Principal($)";

    cout << "Enter Month: " << endl;
    cin >> m;
    cin.ignore();

    if (m == 1){
    p=20000.00;
    cout << Table << endl;
    n=p-y+t+i;
    cout << setw(1) << m <<setw(12) << p <<setw(12) << i <<setw(15) << t <<setw(7) << y <<setw(16) << n << endl;}

    return 1;
}
Why return 1? A return of 0 is the standard-defined "all is good" code, but anyways. This compiles just fine.

What exactly do you need help with? Creating a loop? If so...
http://cplusplus.com/doc/tutorial/control/
...scroll down a bit.

-Albatross

I guess that what you mean is that the number under "New Principal($)" is "0". But it seems to work just fine.

Although there is one thing, it seems that you use string without include the string header, so try this:
1
2
3
4
#include <iostream>                     // <<, >>, cout, cin
#include <cmath>
#include <iomanip>
#include <string> 


EDIT: I read you question a little bit better, and it seems that you question is unclear, but I found a problem in your code anyway.
Last edited on
Topic archived. No new replies allowed.