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

Balance to showbalance. New Balance to get Newbalance from the user. Adjustment

ID: 3612153 • Letter: B

Question

     Balance to showbalance.

    New Balance to get Newbalance from the user.

    Adjustment in order todo the adjustment in balance.

    Annual Interest Rate isused for the calculation of the interest.

    Interest data member toshow the interest amount.

    Deposit () to despiteamount in the account.

     Withdrawal () towithdraw the amount from the bank.

    Balance () functionfor displaying the current balance.

     InterestRate () to setthe interest rate. You must get interest

         rate from theuser.                                        

     AnnualInterest () isused to calculate the interest. The interest

      calculated should be deductedfrom the balance and the new balance

      after the deduction should beshown to the user.

1: Deposit

2: Withdraw

3: Get Balance

4: Set annual interest rate

5: Calculate interest  

Perform appropriate function when users select the option. Ifoption is wrong then display the appropriate message. You shouldalso give option to the user if he/she wants to perform morefunctions.

Explanation / Answer

      Am giving you the sample code snippet for Deposit, Withdraw, and Get Balance .        #include <iostream>       #include <iomanip>       #include <fstream>       #include <string>             using namespace std;              bool deposit(float &,float);                    bool withdrawal(float &,float);                 bool Balance(float &,float);          bool Balance(float &,float);                   const int MAX = 50;                              int main()       {           string user,filename;           string account[MAX], action[MAX];           fstream transaction_file;           float amount[MAX];           float checking_balance,savings_balance;           int i;           int transactions;           checking_balance = 0.00;           savings_balance = 0.00;           transactions = 0;           for(i=0;i<MAX;i++)           {              amount[i] = 0.00;              account[i] = "null";               action[i] = "null";           }           cout << "Welcome to the Bank! " << "Please enter your name: ";           cin >> user;           filename = "...."+user+".txt";           transaction_file.open(filename.data(),ios::in);           while(!transaction_file.eof() && !transaction_file.fail())           {             for(i=0;i<MAX;i++)            {              transaction_file >> account[i] >> action[i] >> amount[i];            }            } transaction_file.close();     for(i=0;i<MAX && account[i] != "null";i++)        transactions++;        cout << " Transaction               Amount     Deposit     Balance" << endl        << "-------------------      --------    ---------    ----------" << endl;       cout << fixed << setprecision(2);      for(i=0;i<transactions;i++)     {       if(account[i]=="Checking" && action[i]=="Deposit")         {               cout << left << setw(25) << "Checking Deposit";           if(deposit(checking_balance,amount[i]))             {                   cout << right << setw(8) << amount[i]                    << right << setw(13) << deposit_balance                   << " " << right << setw(13) << checking_balance << endl;             }         } // deposit        if(account[i]=="Savings" && action[i]=="Deposit")         {            cout << left << setw(25) << "Savings Deposit";           if(deposit(savings_balance,amount[i]))             {              cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;             }         }        } transaction_file.close();     for(i=0;i<MAX && account[i] != "null";i++)        transactions++;        cout << " Transaction               Amount     Deposit     Balance" << endl        << "-------------------      --------    ---------    ----------" << endl;       cout << fixed << setprecision(2);      for(i=0;i<transactions;i++)     {       if(account[i]=="Checking" && action[i]=="Deposit")         {               cout << left << setw(25) << "Checking Deposit";           if(deposit(checking_balance,amount[i]))             {                   cout << right << setw(8) << amount[i]                    << right << setw(13) << deposit_balance                   << " " << right << setw(13) << checking_balance << endl;             }         } // deposit        if(account[i]=="Savings" && action[i]=="Deposit")         {            cout << left << setw(25) << "Savings Deposit";           if(deposit(savings_balance,amount[i]))             {              cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;             }         }
// withdrawal

      if(account[i]=="Checking" && action[i]=="Withdrawal")        {         cout << left << setw(25) << "Checking Withdrawal";          if(withdrawal(checking_balance,amount[i]))             {               cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;             }           else             {               cout << right << setw(8) << amount[i]                    << right << setw(27) << "*Insufficient Funds*" << endl;             }         }
// withdrawal
      if(account[i]=="Savings" && action[i]=="Withdrawal")         {            cout << left << setw(25) << "Savings Withdrawal";           if(withdrawal(savings_balance,amount[i]))             {               cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;             }           else             { cout << right << setw(8) << amount[i]                    << right << setw(27) << "*Insufficient Funds*" << endl;             }         } // checking Balance (from checking to savings)       if(account[i]=="Checking" && action[i]=="Balance")        {          cout << left << setw(25) << "Checking Balance";           if(transfer(checking_balance,savings_balance,amount[i]))             {               cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;             }           else             {               cout << right << setw(8) << amount[i]                    << right << setw(27) << "*Insufficient Funds*" << endl;             }         } // savings Balance (from savings to checking)         if(account[i]=="Savings" && action[i]=="Balance")         {           cout << left << setw(25) << "Checking Balance";           if(transfer(savings_balance,checking_balance,amount[i]))             {               cout << right << setw(8) << amount[i]                    << right << setw(13) << savings_balance                    << " " << right << setw(13) << checking_balance << endl;            }           else             { cout << right << setw(8) << amount[i]                   << right << setw(27) << "*Insufficient Funds*" << endl;             }         }     } // thank user and quit cout << " Thank you for visiting the bank, " << user << endl; return 0; } bool transfer(float &source,float &destination, float amount)
{   if(amount >= 0.0 && amount <= source)     {      withdrawal(source,amount);       deposit(destination,amount);       return (true);     } else     return (false); } bool deposit(float &balance,float amount) {     if(amount >= 0.0)     {      balance += amount;       return (true);     } else     return (false); } bool withdrawal(float &balance,float amount) {     if(amount >= 0.0 && amount <= balance)     {       balance -= amount;       return (true);     } else     return (false); }
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote