What does this mean: 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.

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question
What does this mean: 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.
```cpp
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;
    bool isFound=false;
    infile >> id >> amount;
    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 << "Withdrew $" << amount << " from account #" << id << endl;
        cout << "Current balance is $" << accounts[pos].getBalance() << endl;
    }
}
else if (operationType == "Balance"){
    int id;
    bool isFound=false;
    infile >> id;
    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;
        }
    }
    if(!isFound){
        cout << "Invalid Account Number " << id << endl;
    }
}
else if (operationType == "Close"){
    cout << "Account batch 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 << "Account #" << accounts[i] << accountsString() << endl;
    }
}
else{
    cout << "Unrecognised command " << operationType << endl;
Transcribed Image Text:```cpp 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; bool isFound=false; infile >> id >> amount; 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 << "Withdrew $" << amount << " from account #" << id << endl; cout << "Current balance is $" << accounts[pos].getBalance() << endl; } } else if (operationType == "Balance"){ int id; bool isFound=false; infile >> id; 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; } } if(!isFound){ cout << "Invalid Account Number " << id << endl; } } else if (operationType == "Close"){ cout << "Account batch 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 << "Account #" << accounts[i] << accountsString() << endl; } } else{ cout << "Unrecognised command " << operationType << endl;
```cpp
#include <iostream>
#include <fstream>
#include <string>
using namespace std;

class Account {
    int id;
    double balance;
public:
    Account() {
    }
    Account(int newID, double initialBalance) {
        id = newID;
        balance = initialBalance;
    }
    void setID(int newID) {
        id = newID;
    }
    void setBalance(double initialBalance) {
        balance = initialBalance;
    }
    int getID() {
        return id;
    }
    double getBalance() {
        return balance;
    }
    void withdraw(double amount) {
        balance = balance - amount;
    }
    void deposit(double amount) {
        balance = balance + amount;
    }
    virtual void closeMonth() = 0;
    virtual string accountString() = 0;
};

class Savings: public Account {
    double interest;
    double minBalance;
public:
    Savings() {
    }
    void closeMonth() {
        double pre = getBalance();
        double newBalance = pre * ((pre * (interest/100.0))/12.0);
        setBalance(newBalance);
    }
    string accountString() {
        return "Saving account #" + to_string(getID()) + " has balance of $" + to_string(getBalance());
    }
    void setInterest(double interest) {
        this->interest = interest;
    }
    void setMinBalance(double minBalance) {
        this->minBalance = minBalance;
    }
};

class Checking: public Account {
    double monthlyFee;
    double minBalance;
public:
    Checking() {
    }
    void closeMonth() {
        double newBalance = getBalance() - monthlyFee;
        setBalance(newBalance);
    }
    string accountString() {
        return "Checking account #" + to_string(getID()) + " has balance of $" + to_string(getBalance());
    }
    void setMonthlyFee(double monthlyFee) {
        this->monthlyFee = monthlyFee;
    }
    void setMinBalance(double minBalance) {
        this->minBalance = minBalance;
    }
};

int main() {
    Account *accounts = new Account*[10];
    ifstream infile;
    infile.open("bank.txt");
    if (!infile) {
        cerr << "File cannot be opened" << endl;
        exit(1);
    }
    int totalAccount = 0;
    string operationType;
Transcribed Image Text:```cpp #include <iostream> #include <fstream> #include <string> using namespace std; class Account { int id; double balance; public: Account() { } Account(int newID, double initialBalance) { id = newID; balance = initialBalance; } void setID(int newID) { id = newID; } void setBalance(double initialBalance) { balance = initialBalance; } int getID() { return id; } double getBalance() { return balance; } void withdraw(double amount) { balance = balance - amount; } void deposit(double amount) { balance = balance + amount; } virtual void closeMonth() = 0; virtual string accountString() = 0; }; class Savings: public Account { double interest; double minBalance; public: Savings() { } void closeMonth() { double pre = getBalance(); double newBalance = pre * ((pre * (interest/100.0))/12.0); setBalance(newBalance); } string accountString() { return "Saving account #" + to_string(getID()) + " has balance of $" + to_string(getBalance()); } void setInterest(double interest) { this->interest = interest; } void setMinBalance(double minBalance) { this->minBalance = minBalance; } }; class Checking: public Account { double monthlyFee; double minBalance; public: Checking() { } void closeMonth() { double newBalance = getBalance() - monthlyFee; setBalance(newBalance); } string accountString() { return "Checking account #" + to_string(getID()) + " has balance of $" + to_string(getBalance()); } void setMonthlyFee(double monthlyFee) { this->monthlyFee = monthlyFee; } void setMinBalance(double minBalance) { this->minBalance = minBalance; } }; int main() { Account *accounts = new Account*[10]; ifstream infile; infile.open("bank.txt"); if (!infile) { cerr << "File cannot be opened" << endl; exit(1); } int totalAccount = 0; string operationType;
Expert Solution
steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY