Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Basic C++ help: This is what it is asking. I will need the program to print the

ID: 3925099 • Letter: B

Question

Basic C++ help:

This is what it is asking. I will need the program to print the exact output that is reflected in the example.

Ask the user for an amount to save each month. Assuming a 1% per month interest rate, how many MONTHS will it take the user to save $1000. Add the savings at the END of each month.

For example:

This is what I have so far, but it keeps timing out so I don't think I have the math or loop set up correctly.

#include <iostream>
#include <string>
using namespace std;

int main() {
double amount = 0.0;
double interestTotal = 0.0;
double interest = 0.01;
double total = 0.0;
int months = 0;

cout << "How much do you want to save each month?: ";
cin >> amount;
cout << amount;

do {
     interestTotal = (total + amount) * interest;
     total += amount + interestTotal;
     cout << "Month " << months + 1 << ": $" << interestTotal << " deposited " << amount << " interest earned is " << total;
     months++;
}
while (total <= 1000);
cout << "It took " << months << " months, and you now have $" << total << endl;

return 0;
}

Explanation / Answer

#include <iostream>
#include <string>
using namespace std;

int main() {
double amount = 0.0;
double interestTotal = 0.0;
double interest = 0.01;
double total = 0.0;
int months = 0;

cout << "How much do you want to save each month?: ";
cin >> amount;
cout << amount;

do {
     interestTotal = (total + amount) * interest;
     total = amount + interestTotal;
     cout << "Month " << months + 1 << ": $" << total << " deposited " << amount << " interest earned is " <<interestTotal;
     months++;
}
while (total <= 1000);
cout << "It took " << months << " months, and you now have $" << total << endl;

return 0;
}

//edited total+=amount+interestTotal to //total=amount+interestTotal

// in cout keep exchange total and interestTotal