Question: Hello, I need to write up a program using the do while function and I am stuck. I am currently using Microsoft Visual C++ The

Hello, I need to write up a program using the do while function and I am stuck. I am currently using Microsoft Visual C++ The program sample is Sample run: Enter the annual interest rate on the account (e.g. .04): .02 Enter the starting balance: $10000 How many months have passed since the account was established? 2 Month 1 Total deposits for this month: $100 Total withdrawals for this month: $400 Month 2 Total deposits for this month: $0 Total withdrawals for this month: $100 Ending balance: $ 9632.19 Amount of deposits: $ 100.00 Amount of withdrawals: $ 500.00 Amount of interest earned: $ 32.19 This is where I am currently at, it is a bit all over the place as I remove and re-add code. #include #include #include using namespace std; int main() { double rate, money, startBal; //Interest rate, monetary amount, starting balance int numMonth; //Number of amounts passed char again; //Re-iterate loop cout << "This program will calculate your ending balance" << endl; cout << "With a given balance, interest rate and amount of months "; //Explains program do { cout << "Enter the annual interest rate on the account (e.g. .04): "; //Get interest rate cin >> rate; while ((rate > 1) || (rate < 0)) //Validate interest rate { cout << "Please enter a valid rate. "; cin >> rate; } cout << "Enter starting balance: $"; //Get starting balance cin >> startBal; for (; startBal <= 0;) { cout << "Please enter an initial balance greater than zero: "; //Make sure amount is greater than 0 cin >> startBal; } cout << "How many months have passed since the account was established? "; //Get month amount cin >> numMonth; for (; numMonth <= 0 && numMonth <= 12;) { cout << "Please enter a number between 0 and 12: "; //Make sure month is true cin >> numMonth; double withdrawal, withdrawals, month, months, total; cout << " How many withdrawals did each month have? ";//Withdrawal per month cin >> withdrawal; // Determine each month's withdrawal. for (int numMonth = 1; month <= numMonth; months++) { total = 0; // Initialize the accumulator. for (int withdrawal = 1; withdrawals <= withdrawal; withdrawal++) { double score; cout << "Enter withdrawal " << withdrawal << " for "; cout << "Month 1 " << month << ": "; cin >> withdrawal; total += withdrawal; } double n = 1, // compound interest rate formula : A = P(1 + (r / n)) ^ nt t = (numMonth), //period span A, //investment return result; result = (startBal * (1 + (rate / n))); A = pow(result, (n * t)); cout << " Amount of interest earned:" << result - startBal; cout << " Would you like to enter new numbers? Y/N "; cin >> again; } while (again == 'Y' || again == 'y'); { if (again == 'Y' || again == 'y') return main(); else cout << "Have a good day!"; } return 0; }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!