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!!

11 Years
Discussion Span
Last Post by Infarction

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...


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.

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.