Question: Given Data.txt file: Simple 423456 100 Checking 881023 999 Simple 435920 200 Advanced 129999 405 Credit 123321 -1000 Advanced 122333 1000 Credit 576452 -8000 Checking

 Given Data.txt file: Simple 423456 100 Checking 881023 999 Simple 435920200 Advanced 129999 405 Credit 123321 -1000 Advanced 122333 1000 Credit 576452-8000 Checking 881234 5000 Credit 598763 -10 Credit 578824 -2000 Given MAINprogram: // BASE FILE #include #include #include #include #include // INCLUDE YOUR

Given Data.txt file:

Simple 423456 100 Checking 881023 999 Simple 435920 200 Advanced 129999 405 Credit 123321 -1000 Advanced 122333 1000 Credit 576452 -8000 Checking 881234 5000 Credit 598763 -10 Credit 578824 -2000

Given MAIN program:

// BASE FILE #include #include #include #include #include

// INCLUDE YOUR FILES HERE // You need to have the following classes defined // 1 SimpleSavings // 2 AdvancedSavings // 3 CreditAccount // 4 CheckingAccount // 5 BankAccount

// #include "BankAccount.h" // #include "Any other files you have"

using namespace std;

vector openFile(string); void printList(const vector&); void sortList(vector&); bool updateAccount(vector&);

int main() { vector myList; myList = openFile("Data.txt"); if (myList.size()

sortList(myList); printList(myList);

bool keepGoing; do { keepGoing = updateAccount(myList) ; cout

}

/* * This is the method that allows for the user to * do input into the file as neccessary. * loops while the user types in numbers between 1 and 5 * then does what the user requests * this allows for 1 iteration, the loop is controlled in * the main program. */

bool updateAccount(vector &theList) { int choice = 0; while (choice 5) {

cout > "; cin >> choice;

} // Choice 5 = I QUIT if (choice == 5) return false;

// Choice 4 = run endOfYear on all elements. if (choice == 4) { for (BankAccount *x : theList) { x->endOfYear(); } return true; }

// Choice 3 = run endOfMonth on all elements. if (choice == 3) { for (BankAccount *x : theList) { x->endOfMonth(); } return true; }

// Choice 2 = run withdraw if (choice == 2) { string acc; double amount;

cout "; cin >> acc; cout "; cin >> amount;

for (BankAccount *x : theList) { if (x->getID() == acc) { x->withdraw(amount); return true; } } cout

// Choice 1 = run deposit if (choice == 1) { string acc; double amount;

cout "; cin >> acc; cout "; cin >> amount;

for (BankAccount *x : theList) { if (x->getID() == acc) { x->deposit(amount); return true; } } cout

return false; }

/* * sortList method to sort the data in the List by the * account name. The comparePtr is a submethod * that allows the sort method to use the user defined * &L) {

sort(L.begin(), L.end(), comparePtr); }

/* * printList method to print the Vector of data in order. */ void printList(const vector &L) { for (BankAccount *x : L) { x->printStatus(); } }

/* * This method opens up the provided file and reads * the data line by line creating the neccessary classes * as they are developed. * REQUIRES * SimpleSavings * AdvancedSavings * CreditAccount * CheckingAccount */ vector openFile(string fname) { BankAccount *tmp; vector theList;

ifstream dataFile(fname); if (!dataFile.is_open()) { cerr

string type,ID; double z; while (dataFile >> type) {

dataFile >> ID >> z;

if (type == "Simple") tmp = new SimpleSavings(ID,z); if (type == "Advanced") tmp = new AdvancedSavings(ID,z); if (type == "Credit") tmp = new CreditAccount(ID,z); if (type == "Checking") tmp = new CheckingAccount(ID,z); theList.push_back(tmp); }

return theList; }

CS132 PROGRAMMING ASSIGNMENT Banking Accounts OVERVIEW This activity is designed to have you work with an abstract virtual base class, and a set of derived classes. INSTRUCTIONS In this program you will create a set of unique but similar banking account classes that are designed to model the accounts at a bank. Each of the classes will be based upon a generic/abstract base class, and then you will implement the commands necessary to keep track of them. THE MAIN PROGRAM. Your main program will be provided for you. It will be designed to work in sections. The first section will read data from a file and create the accounts as necessary. The second section will allow the user to make changes to the accounts via data entry. THE BANKACCOUNT CLASS The BankAccount class will be the generic starting point for all your future classes. In it you will hold the following information . Balance Number of deposits made so far. Number of withdrawals made so far. An Account ID String . In addition, you will want the following functions, note that some of these may be virtual, and you may need to create some others as necessary. (cough constructors cough) METHODS GETIDO) The getID() function return the account ID string. DEPOSIT(DOUBLE) The deposit(double) function will allow one to add money to the account and keep track of the number of deposits made. WITHDRAW (DOUBLE) The withdraw(double) function will allow one to remove money from the account and keep track of the number of withdraws made. By default there should never be a negative balance, and an error message should print if it is attempted. ENDOFMONTH(); A function that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed by the following functions: Monthly Interest = Balance * Monthly Interest Rate Balance = Balance + Monthly Interest ENDOFYEAR) A function calls that sets the variables that hold the number of withdrawals, number of deposits and withdrawals to zero, and removes the yearly fee at the end of the year. Note that this is called from the main program, your job is to implement the method, not to call it. PRINTSTATUSO) A function that will print off the current value of the account to the screen, with all of the vital information. OPERATOR In order to sort the accounts, you should create operators or == CONSTRUCTOR BANKACCOUNT(STRING, DOUBLE) The BankAccount and all variations need a constructor that will accept the ID string of the account, and a double for the starting balance. TYPES OF ACCOUNTS SIMPLESAVINGS The SimpleSavings account is the simplest class, that should have the following behavior: * Money can be added with no fee or bonus. Money can be subtracted with no fee or bonus as long as the money is available. If the money requested isn't available, no withdrawal is made. Monthly Interest is a flat 0.5% per month Note that is 0.5% not 50%... There is a $5 yearly fee. When printed out it should look like Simple Account #123456 has $10000.00. O O ADVANCEDSAVINGS The AdvancedSavings that should have the following behavior: Money can be added with no fee or bonus. * Money can be subtracted at will, but every withdrawal carries a fee of $1 per withdrawal after the first one per year. So if I took out $10 per month, on January there would be no fee, there would be a $1 fee, in February, and an $11.00 fee in December; Interest is 1% per month, but that increases to 2% if there is more than ten thousand in the account. There is a $100 yearly fee but this is reduced to $15 if there are no withdrawals during the year. When printed out it should look like Advanced Account #123456 has $10000.00 with 3 withdrawals this year. o CHECKINGACCOUNT The CheckingAccount should have the following behavior: * Money can be deposited with no fee or bonus. Before any withdrawal, this account will determine if the withdrawal will cause the balance to go below $0. If the withdrawal would cause the account to go negative, then a service charge of $15 will be taken from the account but the withdrawal will be made. The balance will become negative and the customer will see a negative balance. * Any additional withdrawals when the account is negative will also result in a $15 charge. * There is no interest on this type of account normally, but at the end of the year, if the amount is negative, then an additional 10% charge is applied to the account. i.e., the user owes 10% more.) * The yearly fee is $5.00 + $0.10 per check(withdrawal) made. Note that this might cause the account to go negative, but the $15 fee will not apply. However this is done before the possible 10% fee is calculated. When printed out it should look like Checking Account #123456 has $2000.00 with 7 withdrawals this year. o CREDITACCOUNT The CreditAccount should have the following behavior: o * This account will tend to be negative. Money can be added only if the account is negative. You should not be allowed to add money if it is already paid off. (Note that you can overpay one time, but that will make it positive). Any withdrawal/charge made on the account will not have any fee on it. Note that if it is closed (see below) then no withdrawal will be successful. An account is late if the account is negative AND less than $100 was deposited that month in total at the end of a month. This will require some work to keep track of during the month. * Every month there is 5% monthly charge on any remaining balance if it is negative. If the account is zero or positive, then there is nothing added. At the end of the year, if the account was late 4 months or more, then the account is marked closed, and no further withdrawals can be made, but it does continue to incur interest and fees until it is paid off. Also reset the monthly counter back to zero. They get a fresh chance at the beginning of each year. There is a $25 yearly fee, but no monthly fee. When printed out it should look like one of the following o Credit Account #123456 owes $1235.00. o Credit Account #123456 owes $1235.00 and is late (month #3). o Credit Account #123456 owes $11235.00 and is currently closed. Credit Account #123455 is overpaid by $123.00 O o SUBMISSION You will be expected to turn the necessary files. Note that this might be two files or possibly more depending on how you arrange it. Before submitting your assignment, include a comment at the beginning of your program with some basic information and a description of the program in your own words. For example: // Suzy Student, C5132, Autumn 2049, Section XX // Programming Assignment #2, 06/07/49 // // This program's behavior is ... Make sure to comment appropriately and document all your major points. CS132 PROGRAMMING ASSIGNMENT Banking Accounts OVERVIEW This activity is designed to have you work with an abstract virtual base class, and a set of derived classes. INSTRUCTIONS In this program you will create a set of unique but similar banking account classes that are designed to model the accounts at a bank. Each of the classes will be based upon a generic/abstract base class, and then you will implement the commands necessary to keep track of them. THE MAIN PROGRAM. Your main program will be provided for you. It will be designed to work in sections. The first section will read data from a file and create the accounts as necessary. The second section will allow the user to make changes to the accounts via data entry. THE BANKACCOUNT CLASS The BankAccount class will be the generic starting point for all your future classes. In it you will hold the following information . Balance Number of deposits made so far. Number of withdrawals made so far. An Account ID String . In addition, you will want the following functions, note that some of these may be virtual, and you may need to create some others as necessary. (cough constructors cough) METHODS GETIDO) The getID() function return the account ID string. DEPOSIT(DOUBLE) The deposit(double) function will allow one to add money to the account and keep track of the number of deposits made. WITHDRAW (DOUBLE) The withdraw(double) function will allow one to remove money from the account and keep track of the number of withdraws made. By default there should never be a negative balance, and an error message should print if it is attempted. ENDOFMONTH(); A function that updates the balance by calculating the monthly interest earned by the account, and adding this interest to the balance. This is performed by the following functions: Monthly Interest = Balance * Monthly Interest Rate Balance = Balance + Monthly Interest ENDOFYEAR) A function calls that sets the variables that hold the number of withdrawals, number of deposits and withdrawals to zero, and removes the yearly fee at the end of the year. Note that this is called from the main program, your job is to implement the method, not to call it. PRINTSTATUSO) A function that will print off the current value of the account to the screen, with all of the vital information. OPERATOR In order to sort the accounts, you should create operators or == CONSTRUCTOR BANKACCOUNT(STRING, DOUBLE) The BankAccount and all variations need a constructor that will accept the ID string of the account, and a double for the starting balance. TYPES OF ACCOUNTS SIMPLESAVINGS The SimpleSavings account is the simplest class, that should have the following behavior: * Money can be added with no fee or bonus. Money can be subtracted with no fee or bonus as long as the money is available. If the money requested isn't available, no withdrawal is made. Monthly Interest is a flat 0.5% per month Note that is 0.5% not 50%... There is a $5 yearly fee. When printed out it should look like Simple Account #123456 has $10000.00. O O ADVANCEDSAVINGS The AdvancedSavings that should have the following behavior: Money can be added with no fee or bonus. * Money can be subtracted at will, but every withdrawal carries a fee of $1 per withdrawal after the first one per year. So if I took out $10 per month, on January there would be no fee, there would be a $1 fee, in February, and an $11.00 fee in December; Interest is 1% per month, but that increases to 2% if there is more than ten thousand in the account. There is a $100 yearly fee but this is reduced to $15 if there are no withdrawals during the year. When printed out it should look like Advanced Account #123456 has $10000.00 with 3 withdrawals this year. o CHECKINGACCOUNT The CheckingAccount should have the following behavior: * Money can be deposited with no fee or bonus. Before any withdrawal, this account will determine if the withdrawal will cause the balance to go below $0. If the withdrawal would cause the account to go negative, then a service charge of $15 will be taken from the account but the withdrawal will be made. The balance will become negative and the customer will see a negative balance. * Any additional withdrawals when the account is negative will also result in a $15 charge. * There is no interest on this type of account normally, but at the end of the year, if the amount is negative, then an additional 10% charge is applied to the account. i.e., the user owes 10% more.) * The yearly fee is $5.00 + $0.10 per check(withdrawal) made. Note that this might cause the account to go negative, but the $15 fee will not apply. However this is done before the possible 10% fee is calculated. When printed out it should look like Checking Account #123456 has $2000.00 with 7 withdrawals this year. o CREDITACCOUNT The CreditAccount should have the following behavior: o * This account will tend to be negative. Money can be added only if the account is negative. You should not be allowed to add money if it is already paid off. (Note that you can overpay one time, but that will make it positive). Any withdrawal/charge made on the account will not have any fee on it. Note that if it is closed (see below) then no withdrawal will be successful. An account is late if the account is negative AND less than $100 was deposited that month in total at the end of a month. This will require some work to keep track of during the month. * Every month there is 5% monthly charge on any remaining balance if it is negative. If the account is zero or positive, then there is nothing added. At the end of the year, if the account was late 4 months or more, then the account is marked closed, and no further withdrawals can be made, but it does continue to incur interest and fees until it is paid off. Also reset the monthly counter back to zero. They get a fresh chance at the beginning of each year. There is a $25 yearly fee, but no monthly fee. When printed out it should look like one of the following o Credit Account #123456 owes $1235.00. o Credit Account #123456 owes $1235.00 and is late (month #3). o Credit Account #123456 owes $11235.00 and is currently closed. Credit Account #123455 is overpaid by $123.00 O o SUBMISSION You will be expected to turn the necessary files. Note that this might be two files or possibly more depending on how you arrange it. Before submitting your assignment, include a comment at the beginning of your program with some basic information and a description of the program in your own words. For example: // Suzy Student, C5132, Autumn 2049, Section XX // Programming Assignment #2, 06/07/49 // // This program's behavior is ... Make sure to comment appropriately and document all your major points

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!