I need to put it as so i can count how many loops happend. I need to keep using the formula "totalAmount = amount + (amount * rate)" until i get a number that is more or equal to 5000. But i also need to count how many times it looped, how am i supposed to do that. I know that i am supposed to use while and counter, but how do i put it together?

/* Program: $5,000.00 or more
Date: 12/14/13
Description: This programs calculates when it will take for money to become $5,000.00 or greater. */
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// Declaration of Variables and Constants
double totalAmount;
double amount;
double rate = 0.075;
// Input
cout << "Enter amount of money you are investing: ";
cin >> amount;
totalAmount = amount + (amount * rate)
// Process and Output
if (totalAmount < 5000)
{
while (totalAmount < 5000)
{
totalAmount = amount + (amount * rate)

/* Program: $5,000.00 or more
Date: 12/14/13
Description: This programs calculates when it will take for money to become $5,000.00 or greater. */
#include <cstdlib>
#include <iostream>
#include <string>
usingnamespace std;
int main()
{
// Declaration of Variables and Constants
double totalAmount;
double amount;
double rate = 0.075;
int counter=0;
// Input
cout << "Enter amount of money you are investing: ";
cin >> amount;
totalAmount = amount + (amount * rate)
// Process and Output
if (totalAmount < 5000)
{
while (totalAmount < 5000)
{
totalAmount = amount + (amount * rate)
counter++;
}
}
cout<<counter;