3/13/ XXXXXXXXXXHW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 1/18 Students: This content is controlled by your instructor, and is not zyBooks content....

1 answer below »
Hi below I attachedthe files that are required for the assignment please read all the requirementsclearly mentioned in the file please don't use complex style of coding as this is an entry level undergraduate course


3/13/2020 1.10. HW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 1/18 Students: This content is controlled by your instructor, and is not zyBooks content. Direct questions or concerns about this content to your instructor. If you have any technical issues with the zyLab submission system, use the Trouble with lab button at the bottom of the lab. 1.10 HW7 This homework assignment gives you the opportunity to practice classes, member variables, member functions, static member variables, dynamic creation of objects, pointers to objects. The homework has an extra credit version worth an additional 15 bonus points. HW7 (Graded out of 100) Design a bank account class named Account that has the following private member variables: • accountNumber of type int • numOwners of type int // number of account co-owners (account can have more than one owner) • ownerPtr of type Person * //, ownerPtr points to an array of Person, where Person is a structure. The Person structure is de�ned below • balance of type double • accountCounter of type static int // initialized at 1000, incremented at each account creation, used to automate account number assignment and the following public member functions: • Account(int numberOwners, double amount) constructor which sets the accountNumber using the value of accountCounter, sets numOwners, dynamically creates an array of Person of the right size, and sets balance to amount. The function then increments accountCounter • ~Account() destructor which releases the array of Person dynamically created in the constructor • withdraw(double amount) function to withdraw a speci�ed amount from the account. The function should �rst check if the amount is > 0 and if there is su�cient balance in the account (greater or equal to the withdrawal amount). If so, withdrawal is processed and the function returns 0. Otherwise the withdrawal is not made and the function returns 1 if the amount > balance, or 2 if the amount is <= 0="" 3/13/2020="" 1.10.="" hw7="" https://learn.zybooks.com/zybook/utdallascecste1337lespring2020/chapter/1/section/10="" 2/18="" •="" deposit(double="" amount)="" function="" to="" deposit="" a="" speci�ed="" amount="" of="" money="" to="" the="" account.="" the="" function="" should="" �rst="" check="" if="" the="" deposit="" amount="" is=""> 0. If so, the deposit is processed and the function returns 0. Otherwise the deposit is not made and the function returns 1. • setOwner(int ind, Person p): A mutator function that assigns Person p to the co-owner at index ind of the ownerPtr array • getOwner(int ind): An accessor that returns the owner at index ind of the ownerPtr array. Return type is Person. • getAccountNumber(): An accessor function that returns the account number. • getBalance(): An accessor function that returns the account balance. • getNumOwners(): An accessor function that returns numOwners. De�ne these structures in Account.h struct Date { int month; int day; int year; }; struct Person // stores account owner’s info { string name; Date DOB; string address; }; Demonstrate in a program. 1. Additional Requirements – Make sure you meet all the requirements to avoid losing points a) What to turn in Your code should be structured into the following �les, but you should turn in only Account.cpp and main.cpp: • Account.h which contains the class de�nition and the function prototypes of all the member functions (no in-line 3/13/2020 1.10. HW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 3/18 member functions) • Account.cpp which contains the function description of all the member functions • main.cpp �le which contains the main function. b) Outline of program Define a global array of pointers to Account, of size MAX_NUM_ACCOUNTS (set MAX_NUM_ACCOUNTS to 4) Account * accountArray[MAX_NUM_ACCOUNTS]; In main, initialize all the elements of the above array with nullptr Loop on displaying the following menu of choices: 1. Create account 2. Deposit to account 3. Withdraw from account 4. Display information for all accounts 5. Delete owner 6. Add owner 7. Delete account 8. Quit If the user selects “Create account” on the menu, the program will prompt the user to enter the number of owners and the amount, dynamically allocate an Account object, and store the address of the created object into the �rst available element of the array of pointers, starting with the one at index 0. Then, owner by owner, the program prompts the user to enter the owner’s info (name, DOB, address) and calls the setOwner mutator to set the owner’s info. If there is no more available element (i.e. the array is full), no dynamic allocation of an Account object is done, and an error message is displayed. The account number is automatically generated from the static variable accountCounter. If the user selects “Deposit”, or “Withdraw”, the program prompts the user to enter the account number and amount and checks that the account number exists. If so, it calls the appropriate member function(s). The appropriate error message is printed if an error indication is returned by the member function. Choices 5, 6 and 7 are placeholders for the extra credit version. For the basic version, if the user selects 5, 6 or 7, the 3/13/2020 1.10. HW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 4/18 program does nothing and displays the menu again. If the user selects “Quit”, the main function should release the dynamically allocated Account objects and terminate. c) Input validation and error messages by main function • The main function should check the account number exists when the user tries to deposit or withdraw. If the account does not exist, the main function prints the appropriate speci�c error message (“No such account”), and no further action is taken. In order to do the checking, your program should perform a search on the account number. • The main function should print the appropriate speci�c error message (“Deposit amount cannot be negative”) if any of the withdraw, deposit member functions returns an error indication. The program does not exit. • The main function should check the maximum number of accounts has not been reached (MAX/NUM/ACCOUNTS) when the user attempts to create an account. If the maximum has been reached, it should display the appropriate speci�c error message (“Maximum number of accounts reached”) 2. Extra Credit (15 points) The extra credit is a superset of the basic version. a). Requirements for extra credit De�ne a global array of pointers to Account, of size MAX_NUM_ACCOUNTS (set MAXNUMACCOUNTS to 4) Account * accountArray[MAXNUMACCOUNTS]; In main, initialize all the elements of the above array with nullptr Loop on displaying the following menu of choices: 1. Create account 2. Deposit to account 3. Withdraw from account 4. Display information for all accounts 5. Delete owner 6. Add owner 7. Delete account 8. Quit 3/13/2020 1.10. HW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 5/18 If the user chooses 1, 2, 3, 4, or 8, the program should behave like in the basic version. If the user chooses 5, the user will be prompted for the account number and the Person to delete. Delete is not performed if there is only one owner in the account. If the user chooses 6, the user will be prompted for the account number and the Person to add. You are not required to check that Person is already an owner of the account. If the user chooses 7, the user will be prompted for the account to delete. The program prints an error message if the account is not found. Implement these additional public member functions: • addOwner(Person): mutator which takes a Person as an argument and adds that Person as an owner of the account. A new array of the right size should be dynamically allocated, all the owner’s info from the current array should be copied to the new array and the current array released. You are not required to check that Person is already an owner of the account. The relative order of the owners should be preserved, and the newly added owner should be last in the new array. • delOwner(Person): mutator which takes a Person as an argument and deletes that Person from the owner(s) of the account. The function should return an int with value 0, 1 or 2, for the cases of “no error”, “Person not found among the owners” and “delete cannot be performed because there is only one owner left” respectively. A new array of the right size should be dynamically allocated, all the owner’s info from the current array should be copied to the new array and the current array released. The relative order of the owners should be preserved in the new array. In addition, when the user chooses “Delete account”, the main function should print an error message if the account is not found. Otherwise, delete is performed and all the relevant data should be updated. The Account object should be released. The "Delete account" operation should not result in any gap in the accountArray array, and should preserve the relative order of the elements in the array. 3. Grading Criteria a) Source code inspection (grader) Style: 10 points (refer to the “Homework Notes” for the style requirements) Required: Dynamic allocation of Account and assignment to the proper element of the accountArray when an account is created: Deduct 10 points if the requirement is not met Required: Dynamic allocation of Person array of the right size in Account constructor: Deduct 10 points if the requirement is not met Required: Use of static variable for accountCounter: Deduct 5 points if the requirement is not met b) Program compilation and execution (zylabs) 3/13/2020 1.10. HW7 https://learn.zybooks.com/zybook/UTDALLASCECSTE1337LeSpring2020/chapter/1/section/10 6/18 Test-1 – Basic case, no error – Output matches output-1: 42 points Test-2 – withdraw and deposit, Account does not exist – Output matches output-2: 9 points Test-3 – Max number of accounts reached – Output matches output-3: 9 points Test-4 – withdraw, invalid amounts – Output matches output-4: 9 points Test-5 – deposit, invalid amount - Output matches output-5: 9 points Test-6 – delete account (Extra credit) – Output matches output-6: 5 points Test-7 – Account-set-getOwners unit tests: 12 points Test-8 – addOwner unit test (Extra credit): 5 points Test-9 – delOwner unit test (Extra credit): 5 points 4. Screen Outputs Below are the expected screen outputs when you execute your code on an IDE. To save you keyboard typing time, you may copy and paste from the “test*-keyboard-input.txt” �les on zylabs. Menu ---- 1->Create account 2->Deposit 3->Withdraw 4->Display 5->Delete owner 6->Add owner 7->Delete accnt 8->Quit 1 Enter number of owners: 1 Enter amount: 100.1 Enter owner's
Answered Same DayMar 14, 2021

Answer To: 3/13/ XXXXXXXXXXHW7...

Arun Shankar answered on Mar 20 2021
137 Votes
class Account
{
    private:
        int accountNumber;
        int numOwners;
        Person ownerPtr;
        double ba
lance;
        static int accountCounter;
        struct Date
        {
         int month;
         int day;
         int year;
        };
        struct Person // stores account owner’s info
        {
         string name;
         Date...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here