Hey everyone, I'm trying to write a simple program that allows the user to input and Amount, Yearly Interest Rate, and a Final Amount. The program is to compute how long the money should be invested to end up with the Final Amount if it is compounded monthly. I'm just learning how to program in C++ so any help is greatly appreciated. I got the basic computations I think but I don't know whether to use a For-Loop or a While-Loop...Please help! Thanks!!

Using a while loop would be a better option.
If you want more help then please post your entire code so that we can help you out.

#include <iostream>
using namespace std;
int main()
{
double amount, rate, mrate, famount;
cout << "Input Initial Amount: ";
cin >> amount;
cout << "Input Yearly Rate: ";
cin >> rate;
cout << "Input Final Amount: ";
cin >> famount;

mrate = rate / 100 / 12;
//This is all I've been able to get...all I need help with is the loop...

do{
blah blah blah
}
while (yearcount!=5)
That should help you a little.

thank you

do{
blah blah blah
}
while (yearcount!=5)
That should help you a little.

Unless I missed something, the loop will go as long as amount < famount , assuming amount is updated to store the amount after a given time period.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.