Menu

[Solved]-1 Date Class Mplement Date Class Following Private Member Variables Month Type Int Day Typ Q37192832

Write the code in C++. Thanks.

1. Date class mplement a Date class that has the following private member variables: month of type int day of type int year o. 3. Account class Account has the following member variables private accountNumber of type int ownerName of type string protprint0: a virtual member function that prints accountNumber, ownerName, balance. This function is called in a few instances i6. Additional Requirements a) What to turn in You should not have any in-line member function and submit the following filesc) Input validation .Show an error message if the withdrawal amount is excessive (result in negative balance for a regular ac7. Implementation Notes For simplicity, you may assume all the data typed is properly formatted (no need to do input validati3. Record a Transaction in history To record a transaction, you should implement recordTransaction, a member function of AccoScreen output sample The below screen output is for output test-1 1->Create regular accnt, 2->Create premium accnt, 3->DeposiAccount created: Premium account , #: 1003, Name : Solo, Balance : 5000.50 Galactic unǐt3 1->Create regular accnt, 2->Create1->Create regular accnt, 2-Create premium accnt, 3->Deposit to accnt 4-Withdraw from accnt, 5->Print info accnts, 6-Quit

1. Date class mplement a Date class that has the following private member variables: month of type int day of type int year of type int hour of type int //hour is in military time, e.g. 23 for 11 PM In what follows, a date will be represented as mm/dd/yyyy/hh and the following member functions: public: set(month day_ year_, hour_) mutator that sets the variables month, day, year, and hour to the parameter values print0: Prints the date in the format “Month dd, yyyy, hh:00”. For example, “March 12,2103, 23:00. getMonth0: accessor that returns the month .getDay0: accessor that returns the day getYearO: accessor that returns the year .getHourO: accessor that returns the hour Do not write a constructor. 2. Transaction structure This structure is declared in Account.h struct Transaction Date date; int transactionType 1, 1, 2 for account creation, deposit and withdrawal respectively double amount; . 3. Account class Account has the following member variables private accountNumber of type int ownerName of type string protected balance of type double .numberAccounts of type static int, initialized to zero transactionHistory of type Transaction*// This variable is declared but not used in the basic version numberTransactions of type int )// This variable is declared but not used in the basic version and the following member functions Account(ownerName, balance_, date_) is the constructor that initializes the account’s member variables ownerName and balance balance_ is the amount deposited when the account is created. accountNumber is set to (numberAccounts+1000) and numberAccounts is incremented. transactionHistory is set to nullptr, numberTransactions set to zero. The date_ is only a place holder for the extra credit version and not used in the basic version. withdraw(amount, date_) a virtual member function to withdraw a specified amount from the account. The function should first check if there is sufficient balance in the account. If the balance is sufficient, withdrawal is processed and the function returns true. Otherwise the withdrawal is not made and the function returns false. If the withdrawal is made, the withdrawal amount is deducted from balance. The date_ is only a place holder for the extra credit version and not used in the basic version deposit(amount, date_) function to deposit a specified amount of money to the account. The function should first check if the deposit amount is positive. If it is positive, deposit is processed and the function returns true. Otherwise the deposit is not made and the function returns false. If the deposit is made, the amount is added to balance. The date_ is only a place holder for the extra credit version and not used in the basic version. . getAccountNumber0: An accessor function that returns the account number. . getBalance0: An accessor function that returns the account balance getNumberAccounts0: A static member function that returns numberAccounts print0: a virtual member function that prints accountNumber, ownerName, balance. This function is called in a few instances in main, print0: a virtual member function that prints accountNumber, ownerName, balance. This function is called in a few instances in main, including when the user chooses “print info for all accounts 4. RegularAccount class Implement a RegularAccount class that is derived from the Account class it has the following public members RegularAccount(ownerName balance_ date_) is the constructor which passes the arguments to the Account constructor print0: overrides the print0 of Account. This function prints the string “Regular account” then prints accountNumber, ownerName, balance To print the accountNumber, ownerName, balance, call the print function of Account with this statement: this->Account print0 5. PremiumAccount class Implement a PremiumAccount class that is derived from the Account class. In addition to the inherited members, it has the following private member variables: MIN BALANCE of type static double, initialized to 1000. The customer of a premium account is required to maintain a balance of at least MIN BALANCE galactic units and the following public member functions PremiumAccount(name, amount) is the constructor which passes the arguments to the Account constructor withdraw(amount, date): overrides the withdraw0 of Account. The function should first check if the existing balance is greater or equal to the withdrawal amount+ MIN BALANCE. If so, withdrawal is processed and the function returns true. Otherwise the withdrawal is not made and the function returns false. If the withdrawal is made, the withdrawal amount is deducted from balance. The date_ is only a place holder for the extra credit version and not used in the basic version. getMinBalance0:A static member function that returns MIN_BALANCE print0: overrides the print0 of Account. This function prints the string “Premium account” then prints accountNumber, ownerName, balance. To print the accountNumber, ownerName, balance, call the print function of Account with this statement: this->Account:print0 6. Additional Requirements a) What to turn in You should not have any in-line member function and submit the following files main.cpp Account.cpp PremiumAccount.cpp RegularAccount.cpp b) Outline of main const int MAX_NUM ACCOUNTS 5; Account accountArray [MAXNUM ACCOUNTS1: Lo p on dǐ3playing the f 11 wing menu f choice3 : 1. Create regular account (user will be prompted for name, date, amount) 2. Create premium account (user will be prompted for name,date, amount) 3. Deposit to account (user will be prompted for account number, date, amount) 4. Withdraw from account (user will be prompted for account number, date, amount) Print info for all accounts Quit When the user chooses to create an account, an account of the appropriate type (regular or premium) should be dynamically created and assigned to the first available element of the accountArray array. The first available element is the element at lowest index which is available c) Input validation .Show an error message if the withdrawal amount is excessive (result in negative balance for a regular account or a balance less than MIN BALANCE for a premium account). No withdrawal should be made in that case .Show an error message if any deposit or withdrawal amount is not >0. No transaction should be made in that case. The main function does the checking and prints the error message. This checking is on top of the checking done in the deposit function. In the context of this HW the amount passed to the deposit function will always be>0. However, the deposit function should still implement the checking, as the Account class may be used in a different context. .Show an error message if the user tries to deposit to or withdraw from an account that has not been created Do not accept to create an account if the maximum number of accounts (MAX NUM_ ACCOUNTS) has been reached .Show an error message if the user attempts to create a regular account with an amount that is not> 0. The account is not created. The checking should be done in the main function . Show an error message if the user attempts to create a premium account with an amount less than MIN_BALANCE. The account is not created. The checking should be done in the main function. d) Output formatting All money amounts should be printed with two digits after the decimal point. e) Style Make sure you follow the style requirements, especially regarding the comment header for functions, to avoid losing points 7. Implementation Notes For simplicity, you may assume all the data typed is properly formatted (no need to do input validation). You may assume none of the data items (names, addresses, etc.) contain a whitespace. Therefore, you don’t need to use getline and should use only inFile .. That will avoid the getline compatibility issues between the Windows, Linux and MAC platforms In some functions, the date_ is only a place holder for the extra credit version and not used in the basic version. You may have a compiler warning that the variable is not used, but that should be expected To pass the unit test, your printTransactions function should be self contained. In particular, it should set the appropriate stream manipulators to print all doubles with two digits after the decimal point Extra Credit For the extra credit, the program should also print the history of transactions when the user chooses Print info for all accounts. .Account class The Account class should be modified as follows Add these members protected recordTransaction(Transaction t): Add t to the transactionHistory, returns void. Details on the function are provided below. public: printTransactions0: Accessor that prints the array of transactions, returns void. This function is called by the main function when the user chooses print info for all accounts These members are modified as follows Account(ownerName_, balance_ date_) is the constructor that initializes the account’s member variables ownerName and balance. balance_ is the amount deposited when the account is created. accountNumber is set to (numberAccounts+1000) and numberAccounts is incremented. transactionHistory is set to nullptr, numberTransactions set to zero. A Transaction structure is statically created and populated with this account creation. The recordTransaction function is called to record the account creation in the transaction history numberTransactions is incremented. We were unable to transcribe this image3. Record a Transaction in history To record a transaction, you should implement recordTransaction, a member function of Account, which takes as argument a Transaction to be recorded. The transaction history is implemented as an array of Transaction structures. Initially, the history is empty and no array is allocated. The first transaction is recorded in the history (account creation is the first transaction) by dynamically allocating an array of size 1, and populating with the transaction to be recorded. /* This function takes as argument a Transaction structure variable and adds it to the transaction history. The transaction history is implemented as an array of Transactions. A new array is dynamically allocated, of size equal to (size of old array) +1, to hold the added transaction. The values of the old azray aze copied into the new array. and the transaction to be added is copied into the last element of the new array. The old array is released through delete. The address returned from dynamic array allocation is assigned to transactionHistory void Account::recordTransaction (Transaction t) //Function body Grading criteria a) Source code inspection (grader) Style: 5 points (refer to the “Homework Notes for the style requirements) Use of base class pointers: dynamically create RegularAccounts and PremiumAccounts and assign to an element of accountArray: 20 points Screen output sample The below screen output is for output test-1 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner s name: R2-D2 Enter date, in the mm/dd/yyyy/hh format: 06/06/2200/01 Enter amount: 8001.1 Account created: Regular account, #: 1000, Name : R2-D2, Balance : 8001.10 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner 3 name: Mr. Spock Enter date, in the mm/dd/yyyy/hh format: 06/05/2100/02 Enter amount: 5000.22 Account created: Premium account , 1001, Name : Mr . Spock, Balance : 5000.22 Galactic units 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner s name: Chewy Enter date, in the mm/dd/yyyy/hh format: 07/07/2200/03 Enter amount: 2000.11 Account created: Regular account, #: 1002, Name : Chewy, Balance: 2000.11 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner’ s name: Solo Enter date, in the mm/dd/yyyy/hh format: 06/05/2100/04 Enter amount: 5000.5 Account created: Premium account , #: 1003, Name : Solo, Balance : 5000.50 Galactic unǐt3 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/05/2199/05 Enter amount: 400.1 Withdraw executed: Premium account , #: 1003, Name : Solo, Balance : 4600.40 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/05/2200/06 Enter amount: 10000.56 Deposit executed: Premium account , 1003, Name : Solo, Balance : 14600.96 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/15/2200/07 Enter amount: 555.7 Deposit executed: Premium account, 1003, Name : Solo, Balance : 15156.66 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/16/2200/08 Enter amount: 2000.9 Deposit executed: Premium account , #: 1003, Name : Solo, Balance : 17157.56 Galactic unit 1->Create regular accnt, 2-Create premium accnt, 3->Deposit to accnt 4-Withdraw from accnt, 5->Print info accnts, 6-Quit Show transcribed image text 1. Date class mplement a Date class that has the following private member variables: month of type int day of type int year of type int hour of type int //hour is in military time, e.g. 23 for 11 PM In what follows, a date will be represented as mm/dd/yyyy/hh and the following member functions: public: set(month day_ year_, hour_) mutator that sets the variables month, day, year, and hour to the parameter values print0: Prints the date in the format “Month dd, yyyy, hh:00”. For example, “March 12,2103, 23:00. getMonth0: accessor that returns the month .getDay0: accessor that returns the day getYearO: accessor that returns the year .getHourO: accessor that returns the hour Do not write a constructor. 2. Transaction structure This structure is declared in Account.h struct Transaction Date date; int transactionType 1, 1, 2 for account creation, deposit and withdrawal respectively double amount;
. 3. Account class Account has the following member variables private accountNumber of type int ownerName of type string protected balance of type double .numberAccounts of type static int, initialized to zero transactionHistory of type Transaction*// This variable is declared but not used in the basic version numberTransactions of type int )// This variable is declared but not used in the basic version and the following member functions Account(ownerName, balance_, date_) is the constructor that initializes the account’s member variables ownerName and balance balance_ is the amount deposited when the account is created. accountNumber is set to (numberAccounts+1000) and numberAccounts is incremented. transactionHistory is set to nullptr, numberTransactions set to zero. The date_ is only a place holder for the extra credit version and not used in the basic version. withdraw(amount, date_) a virtual member function to withdraw a specified amount from the account. The function should first check if there is sufficient balance in the account. If the balance is sufficient, withdrawal is processed and the function returns true. Otherwise the withdrawal is not made and the function returns false. If the withdrawal is made, the withdrawal amount is deducted from balance. The date_ is only a place holder for the extra credit version and not used in the basic version deposit(amount, date_) function to deposit a specified amount of money to the account. The function should first check if the deposit amount is positive. If it is positive, deposit is processed and the function returns true. Otherwise the deposit is not made and the function returns false. If the deposit is made, the amount is added to balance. The date_ is only a place holder for the extra credit version and not used in the basic version. . getAccountNumber0: An accessor function that returns the account number. . getBalance0: An accessor function that returns the account balance getNumberAccounts0: A static member function that returns numberAccounts print0: a virtual member function that prints accountNumber, ownerName, balance. This function is called in a few instances in main,
print0: a virtual member function that prints accountNumber, ownerName, balance. This function is called in a few instances in main, including when the user chooses “print info for all accounts 4. RegularAccount class Implement a RegularAccount class that is derived from the Account class it has the following public members RegularAccount(ownerName balance_ date_) is the constructor which passes the arguments to the Account constructor print0: overrides the print0 of Account. This function prints the string “Regular account” then prints accountNumber, ownerName, balance To print the accountNumber, ownerName, balance, call the print function of Account with this statement: this->Account print0 5. PremiumAccount class Implement a PremiumAccount class that is derived from the Account class. In addition to the inherited members, it has the following private member variables: MIN BALANCE of type static double, initialized to 1000. The customer of a premium account is required to maintain a balance of at least MIN BALANCE galactic units and the following public member functions PremiumAccount(name, amount) is the constructor which passes the arguments to the Account constructor withdraw(amount, date): overrides the withdraw0 of Account. The function should first check if the existing balance is greater or equal to the withdrawal amount+ MIN BALANCE. If so, withdrawal is processed and the function returns true. Otherwise the withdrawal is not made and the function returns false. If the withdrawal is made, the withdrawal amount is deducted from balance. The date_ is only a place holder for the extra credit version and not used in the basic version. getMinBalance0:A static member function that returns MIN_BALANCE print0: overrides the print0 of Account. This function prints the string “Premium account” then prints accountNumber, ownerName, balance. To print the accountNumber, ownerName, balance, call the print function of Account with this statement: this->Account:print0
6. Additional Requirements a) What to turn in You should not have any in-line member function and submit the following files main.cpp Account.cpp PremiumAccount.cpp RegularAccount.cpp b) Outline of main const int MAX_NUM ACCOUNTS 5; Account accountArray [MAXNUM ACCOUNTS1: Lo p on dǐ3playing the f 11 wing menu f choice3 : 1. Create regular account (user will be prompted for name, date, amount) 2. Create premium account (user will be prompted for name,date, amount) 3. Deposit to account (user will be prompted for account number, date, amount) 4. Withdraw from account (user will be prompted for account number, date, amount) Print info for all accounts Quit When the user chooses to create an account, an account of the appropriate type (regular or premium) should be dynamically created and assigned to the first available element of the accountArray array. The first available element is the element at lowest index which is available
c) Input validation .Show an error message if the withdrawal amount is excessive (result in negative balance for a regular account or a balance less than MIN BALANCE for a premium account). No withdrawal should be made in that case .Show an error message if any deposit or withdrawal amount is not >0. No transaction should be made in that case. The main function does the checking and prints the error message. This checking is on top of the checking done in the deposit function. In the context of this HW the amount passed to the deposit function will always be>0. However, the deposit function should still implement the checking, as the Account class may be used in a different context. .Show an error message if the user tries to deposit to or withdraw from an account that has not been created Do not accept to create an account if the maximum number of accounts (MAX NUM_ ACCOUNTS) has been reached .Show an error message if the user attempts to create a regular account with an amount that is not> 0. The account is not created. The checking should be done in the main function . Show an error message if the user attempts to create a premium account with an amount less than MIN_BALANCE. The account is not created. The checking should be done in the main function. d) Output formatting All money amounts should be printed with two digits after the decimal point. e) Style Make sure you follow the style requirements, especially regarding the comment header for functions, to avoid losing points
7. Implementation Notes For simplicity, you may assume all the data typed is properly formatted (no need to do input validation). You may assume none of the data items (names, addresses, etc.) contain a whitespace. Therefore, you don’t need to use getline and should use only inFile .. That will avoid the getline compatibility issues between the Windows, Linux and MAC platforms In some functions, the date_ is only a place holder for the extra credit version and not used in the basic version. You may have a compiler warning that the variable is not used, but that should be expected To pass the unit test, your printTransactions function should be self contained. In particular, it should set the appropriate stream manipulators to print all doubles with two digits after the decimal point Extra Credit For the extra credit, the program should also print the history of transactions when the user chooses Print info for all accounts. .Account class The Account class should be modified as follows Add these members protected recordTransaction(Transaction t): Add t to the transactionHistory, returns void. Details on the function are provided below. public: printTransactions0: Accessor that prints the array of transactions, returns void. This function is called by the main function when the user chooses print info for all accounts These members are modified as follows Account(ownerName_, balance_ date_) is the constructor that initializes the account’s member variables ownerName and balance. balance_ is the amount deposited when the account is created. accountNumber is set to (numberAccounts+1000) and numberAccounts is incremented. transactionHistory is set to nullptr, numberTransactions set to zero. A Transaction structure is statically created and populated with this account creation. The recordTransaction function is called to record the account creation in the transaction history numberTransactions is incremented.

3. Record a Transaction in history To record a transaction, you should implement recordTransaction, a member function of Account, which takes as argument a Transaction to be recorded. The transaction history is implemented as an array of Transaction structures. Initially, the history is empty and no array is allocated. The first transaction is recorded in the history (account creation is the first transaction) by dynamically allocating an array of size 1, and populating with the transaction to be recorded. /* This function takes as argument a Transaction structure variable and adds it to the transaction history. The transaction history is implemented as an array of Transactions. A new array is dynamically allocated, of size equal to (size of old array) +1, to hold the added transaction. The values of the old azray aze copied into the new array. and the transaction to be added is copied into the last element of the new array. The old array is released through delete. The address returned from dynamic array allocation is assigned to transactionHistory void Account::recordTransaction (Transaction t) //Function body Grading criteria a) Source code inspection (grader) Style: 5 points (refer to the “Homework Notes for the style requirements) Use of base class pointers: dynamically create RegularAccounts and PremiumAccounts and assign to an element of accountArray: 20 points
Screen output sample The below screen output is for output test-1 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner s name: R2-D2 Enter date, in the mm/dd/yyyy/hh format: 06/06/2200/01 Enter amount: 8001.1 Account created: Regular account, #: 1000, Name : R2-D2, Balance : 8001.10 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner 3 name: Mr. Spock Enter date, in the mm/dd/yyyy/hh format: 06/05/2100/02 Enter amount: 5000.22 Account created: Premium account , 1001, Name : Mr . Spock, Balance : 5000.22 Galactic units 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner s name: Chewy Enter date, in the mm/dd/yyyy/hh format: 07/07/2200/03 Enter amount: 2000.11 Account created: Regular account, #: 1002, Name : Chewy, Balance: 2000.11 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter owner’ s name: Solo Enter date, in the mm/dd/yyyy/hh format: 06/05/2100/04 Enter amount: 5000.5
Account created: Premium account , #: 1003, Name : Solo, Balance : 5000.50 Galactic unǐt3 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/05/2199/05 Enter amount: 400.1 Withdraw executed: Premium account , #: 1003, Name : Solo, Balance : 4600.40 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/05/2200/06 Enter amount: 10000.56 Deposit executed: Premium account , 1003, Name : Solo, Balance : 14600.96 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/15/2200/07 Enter amount: 555.7 Deposit executed: Premium account, 1003, Name : Solo, Balance : 15156.66 Galactic unit 1->Create regular accnt, 2->Create premium accnt, 3->Deposit to accnt 4->Withdraw from accnt, 5->Print info accnts, 6->Quit Enter account number: 1003 Enter date, in the mm/dd/yyyy/hh format: 06/16/2200/08 Enter amount: 2000.9 Deposit executed: Premium account , #: 1003, Name : Solo, Balance : 17157.56 Galactic unit
1->Create regular accnt, 2-Create premium accnt, 3->Deposit to accnt 4-Withdraw from accnt, 5->Print info accnts, 6-Quit

Expert Answer


Answer to 1. Date class mplement a Date class that has the following private member variables: month of type int day of type int y… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *