im writing a program that should loop for the number of months that the user inputs
this kinda works but was trying to keep looping for the number of months entered if a user inputs 4 months that the account has been open it should loop 4 times asking the following:
a. the amount deposited ie i enter 10 and want to be able to enter another depost during the month ie 1350.00, 323.49, etc
hmmm?
b. how do I not accept negative numbers for this account? hmm...
c. ditto for the amount withdrawn
d. and I aslo would like to be able to break out of the break out of the loop and close the account if balance = 0 anytime during it execution.
here is what I have so far.....
any help would be greatly appreciatedCode:#include <iostream> using namespace std; int main() /*function main*/ { float bal = 0; float rate = 0; float intearned = 0; int months = 0; int deposit = 0; int withdrawal= 0; cout <<"Please enter the your balance $: (-1 to stop) "; cin >> bal; cout <<"What is the interest rate? (-1 to stop) "; cin >> rate; cout <<"How many months has the account been established (-1 to stop) "; cin >> months; while (months >= 1) { cout <<"Please enter any deposits this month $: (-1 to stop) "; cin >> deposit; bal += deposit; bal += (rate) * months/12; intearned = (rate * months/12); months++; cout <<"Please enter any withdrawals this month $: (-1 to stop) "; cin >> withdrawal; bal -= withdrawal; // if (withdrawal = -1) // if (deposit = -1) break; } cout <<'\n'; cout << "The balance is " << bal << endl; //print output cout << "The total deposits are: " << deposit << endl; cout << "The total withdrawals are: " << withdrawal << endl; cout << "The total interest earned is : " << intearned << endl; return 0; }//end main