namespace

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

#include "Bank.h"

#include <iostream>
#include <fstream>
#include <string>
#include <vector>

using namespace std;

int main() {
    Account** accounts = new Account * [10];
    ifstream infile;
    infile.open("bank2.txt");
    if ( !infile )
        cerr << "File cannot be opened" << endl;
    else
        cout << "File Opened" << endl;

    string operationType;
    int totalAccount = 0;

    while (infile >> operationType) {
        if (operationType == "Saving") {
            int id;
            double initialBalance, minimumBalance, annualInterestRate;
            infile >> id >> initialBalance >> minimumBalance >> annualInterestRate;
            Saving* savingAccount = new Saving();
            savingAccount->setInterest(annualInterestRate);
            savingAccount->setMinBalance(minimumBalance);
            accounts[totalAccount] = savingAccount;
            accounts[totalAccount]->setID(id);
            accounts[totalAccount]->setBalance(initialBalance);
            totalAccount++;
            cout << "Saving account number " << totalAccount << " created" << endl;
            cout << "with an initial balance of $" << accounts[totalAccount - 1]->getBalance() << endl;
        }
        else if (operationType == "Checking") {
            int id;
            double initialBalance, minimumBalance, monthlyFees;
            infile >> id >> initialBalance >> minimumBalance >> monthlyFees;
            Checking* checkingAccount = new Checking();
            checkingAccount->setMonthlyFee(monthlyFees);
            checkingAccount->setMinBalance(minimumBalance);
            accounts[totalAccount] = checkingAccount;
            accounts[totalAccount]->setID(id);
            accounts[totalAccount]->setBalance(initialBalance);
            totalAccount++;
            cout << "Checking account number " << totalAccount << " created" << endl;
            cout << "with an initial balance of $" << accounts[totalAccount - 1]->getBalance() << endl;
        }
        else if (operationType == "Deposit") {
            int id;
            double amount;
            int pos;
            bool isFound = false;
            infile >> id >> amount;
            for (int i = 0; i < totalAccount; i++) {
                if (accounts[i]->getID() == id) {
                    isFound = true;
                    accounts[i]->deposit(amount);
                    pos = i;
                }
            }
            if (!isFound) {
                cout << "Invalid Account Number - " << id << endl;
            }
            else {
                cout << "Deposited $" << amount << " into account #" << id << endl;
                cout << "current balance is $" << accounts[pos]->getBalance() << endl;
            }
        }
        else if (operationType == "Withdraw") {
            int id;
            double amount;
            int pos;
            infile >> id >> amount;
            bool isFound = false;
            for (int i = 0; i < totalAccount; i++) {
                if (accounts[i]->getID() == id) {
                    isFound = true;
                    accounts[i]->withdraw(amount);
                    pos = i;
                }
            }
            if (!isFound) {
                cout << "Invalid Account Number - " << id << endl;
            }
            else {
                cout << "Withdraw $" << amount << " from account #" << id << endl;
                cout << "current balance is $" << accounts[pos]->getBalance() << endl;
            }
        }
        else if (operationType == "Balance") {
            int id;
            infile >> id;
            int pos;
            bool isFound = false;
            for (int i = 0; i < totalAccount; i++) {
                if (accounts[i]->getID() == id) {
                    isFound = true;
                    cout << "current balance in account #" << id << " is $" << accounts[i]->getBalance() << endl;
                    pos = i;
                }
            }
            if (!isFound) {
                cout << "Invalid Account Number - " << id << endl;
            }
        }
        else if (operationType == "Close") {
            cout << "End of month processing complete" << endl;
            for (int i = 0; i < totalAccount; i++) {
                accounts[i]->closeMonth();
            }
        }
        else if (operationType == "Report") {
            for (int i = 0; i < totalAccount; i++) {
                cout << accounts[i]->accountString() << endl;
            }
        }
        else {
            cout << "Unrecognised command - " << operationType << endl;
            string dummyLine;
            getline(infile, dummyLine);
        }
    }
    infile.close();
}

The text highlights an issue with end-of-month financial processing:

"This does not handle the end of month processing correctly. The monthly fee should only be deducted if the balance is below the minimum. Similarly, the interest should only be added if the balance is above the minimum. Please correct and resubmit."

Explanation:
- The message indicates that the current system incorrectly processes monthly fees and interest.
- Monthly fees need to be deducted only when account balances fall below a minimum threshold.
- Interest should be credited only when account balances are above this threshold.
- Users are requested to correct these errors and resubmit their work for review.
Transcribed Image Text:The text highlights an issue with end-of-month financial processing: "This does not handle the end of month processing correctly. The monthly fee should only be deducted if the balance is below the minimum. Similarly, the interest should only be added if the balance is above the minimum. Please correct and resubmit." Explanation: - The message indicates that the current system incorrectly processes monthly fees and interest. - Monthly fees need to be deducted only when account balances fall below a minimum threshold. - Interest should be credited only when account balances are above this threshold. - Users are requested to correct these errors and resubmit their work for review.
**End of Month Financial Summary**

- **Saving Account a1**: Balance of $1014.39
- **Checking Account a2**: Balance of $2015.09
- **Saving Account a3**: Balance of $3051.05
- **Checking Account a4**: Balance of $3987.65

This financial summary illustrates the end-of-month balances for a set of savings and checking accounts. Each account is identified by a unique code (a1, a2, etc.) and displays the precise balance in U.S. dollars.
Transcribed Image Text:**End of Month Financial Summary** - **Saving Account a1**: Balance of $1014.39 - **Checking Account a2**: Balance of $2015.09 - **Saving Account a3**: Balance of $3051.05 - **Checking Account a4**: Balance of $3987.65 This financial summary illustrates the end-of-month balances for a set of savings and checking accounts. Each account is identified by a unique code (a1, a2, etc.) and displays the precise balance in U.S. dollars.
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
Module hierarchy chart
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education