Hi I am very new to C++ and I was told to make a program that start with the ammount you choose but it has compound interest of 6% a year (0.5% a month) and you take out 500 dollars a month, at what months and years would the account be depleted...

I started by

#include <iostream>

using namespace std;   //introduces namespace std
int main()
        float ibalance;
        int month, year, interest, withdrawn;

//inputting balance
        cout << "Enter Balance: ";
        cin >> ibalance;

//starting of loop for month
    for (month= 0; month < 12; month++);

    cout << month << endl;

return 0       

I am very lost on how to put interest and withdrawn and with with the Year loop... any tips on how i can continue?

Edited by Dani: Formatting fixed

8 Years
Discussion Span
Last Post by kolosick.m188

Try, instead of a for loop, using while (ibalance != 0) Also, just calculate the interest, subtract the 500 from ibalance, and increment the month during the while loop. Then when you want to find out how long it took change the number of months into months and years

Edited by kolosick.m188: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.