I am trying to print out a report for a 12 month interest summary. So far, I cannot seem to get the ending balance for the previous month to be the starting balance for the next month. I can't seem to get the loop to work. It should read:
#include <iostream>
#include <string>
#include <iomanip>
usingnamespace std;
#include "SavingsAccount.h"
int main()
{
//Create one instance of a SavingsAccount
SavingsAccount myAccount("Z1234A", 4000.0, 0.004);
double currentBalance;
char makeDeposit = ' ';
double amount = 0.0;
char makeWithdrawal = ' ';
double INT_RATE = .004;
double endingBal = 0.0;
//Set decimal spaces to 2
cout << fixed << setprecision(2);
string accountNumber;
accountNumber = myAccount.getAcctNo();
//Display the name of software and company
cout << setw(55) << " BANKING SOLUTIONS SOFTWARE 1.0 " << endl;
cout << setw(54) << "Prioleau Banking Corporation " << endl << endl;
//Welcome the customer
cout << setw(61) << "Welcome to the Prioleau Banking Corporation!" << endl << endl;
//Display the current state of the account including
//account number, current balance and interest rate
accountNumber = myAccount.getAcctNo();
cout << "Your account number is: " << accountNumber << endl;
currentBalance = myAccount.getBalance();
cout << "Your current balance is: $" << currentBalance << endl;
double startingRate;
startingRate = myAccount.getInterestRate();
cout << "The current interest rate is: " << ".4%" << endl << endl;
//Customer makes a deposit
cout << "Will you be making a deposit today (Y or N)?" << endl;
cin >> makeDeposit;
cout << endl;
if (toupper(makeDeposit) == 'Y')
{
cout << "Please enter the amount that you would like to deposit." << endl;
cin >> amount;
cout << endl;
myAccount.addToBalance(amount);
currentBalance = myAccount.getBalance();
//Display the ending state of the account
cout << "Your current balance is now: $" << currentBalance << endl << endl;
}
else
cout << "Thank you." << endl << endl;
//Customer makes a withdrawal
cout << "Will you be making a withdrawal today (Y or N)?" << endl;
cin >> makeWithdrawal;
cout << endl;
if (toupper(makeWithdrawal) == 'Y')
{
cout << "Please enter the amount that you would like to withdraw." << endl;
cin >> amount;
cout << endl;
myAccount.withdrawFromBalance(amount);
currentBalance = myAccount.getBalance();
//Display the ending state of the account
cout << "Your current balance is now: $" << currentBalance << endl << endl;
}
else
cout << "Thank you." << endl << endl;
//Display a 12-month summary of the account that shows the effect
//of the current interest rate on the growth of the balance
//assuming that the interest is applied as simple interest once per month
cout << "As of today's balance, here is a 12-month summary of the account that "<<
"shows the effect of the current interest rate on the growth " <<
"of the balance; assuming that the interest is applied as simple interest "<<
"once per month." << endl << endl << endl;
//Headers
cout << "Month" << setw(20) << "Starting" << setw(20) << "Interest" << setw(20)
<< "Ending" << endl;
cout << " #" << setw(21) << "Balance" << setw(19) << "Earned" << setw(23)
<< "Balance" << endl;
//line number variable for print out
int lineNum = 1;
//Formula for ending balance
endingBal = currentBalance + (currentBalance * INT_RATE);
//12 month interest report output line 1
cout << setw(3) << lineNum << setw(21) << currentBalance + INT_RATE << setw(18) << currentBalance * INT_RATE
<< setw(24) << endingBal;
cout << endl;
while (lineNum <= 11)
{
//Line number counter for 12 month interest report output
lineNum += 1;
//12 month of interest report output
cout << setw(3) << lineNum << setw(21) << endingBal + INT_RATE << setw(18) << currentBalance * INT_RATE
<< setw(24) << endingBal;
cout << endl;
}
//end while
//Thank customer and exit program
cout << endl << endl;
cout << "Thank you for choosing Prioleau Banking Corporation. Have a wonderful day!" << endl;
cout << endl << endl;
system ("pause");
return 0;
}