Implement class BankAcct, for Bank of USQ, using bankacct.cpp and bankacct.h:
- The BSB for Bank of USQ at Towoomba is 324-001.
- A BankAcct object will have a 3 digit bank account number larger than 100 which is a serial number generated by a Serial object. E.g. 324-001-101, 324-001-102, 324-001-103 are the first three possible bank account number for Bank of USQ.
- A BankAcct object will have a bank account pin code which is a 4 digit random number generated by a RandomInt object.
- Class BankAcct should provide a member function to screen display the bank BSB plus account number and the pin code.
Implement an application bankUSQ_app.cpp:
- It will read bankUSQ_account.txt and print out all accounts and pins from the file.
- It will ask user input for the number of bank accounts to generate, and the starting account number.
- Uses class Serial and class RandomInt to generate the account number and the pin code.
- Create BankAcct objects to hold the account number and pin code.
- The BSB (324-001) can be hard coded for screen display only. You do not need to write BSB as part of the account number in bankUSQ_account.txt.
- All generated bank accounts will be store in a vector.
- Before the application exits, it will append the generated accounts to an existing text file named bankUSQ_account.txt. You will need to create an empty bankUSQ_account.txt
before you run the application for the first time.
- Repeat the above steps until the number of bank accounts to generate is 0.
- Assume that all bank accounts generated in each call of the application are unique and not overlapping.
Use Exception to check
- The number of accounts to be created is less than 10. (Assume no negative integers entered.)
- If the input is not valid, the program will ask for user input again.
- You have to use BankError class which is derived from logic_error for exception handling.
- Implement BankError in bankUSQ_app.cpp.
Submit bankacct.cpp, bankacct.h, and bankUSQ_app.cpp and task3.txt. RandomInt class and Serial class files are the same as in Task 1 and 2.
/* Expected output
// bankUSQ_account.txt is empty
Account number: 324-001-1975521678
Pin Code: 0
// 13 is too many, ask for input again
Enter the number of bank account ( < 10), 0 to quit:
13
Too many accounts requested. You requested 13 account numbers. Enter
the number
of bank account ( < 10), 0 to quit:
// 2 is OK
Enter the number of bank account ( < 10), 0 to quit:
2
Enter the start value of account number:
111
Account number: 324-001-111
Pin Code: 8327
Account number: 324-001-112
Pin Code: 3620
// another 2
Enter the number of bank account ( < 10), 0 to quit:
2
Enter the start value of account number:
222
Account number: 324-001-222
Pin Code: 8350
Account number: 324-001-223
Pin Code: 7554
Enter the number of bank account ( < 10), 0 to quit:
0
Quit ...
c\>a
// There are 4 accounts in bankUSQ_account.txt
Account number: 324-001-111
Pin Code: 8327
Account number: 324-001-112
Pin Code: 3620
Account number: 324-001-222
Pin Code: 8350
Account number: 324-001-223
Pin Code: 7554
// too many
Enter the number of bank account ( < 10), 0 to quit:
45
Too many accounts requested. You requested 45 account numbers. Enter
the number
of bank account ( < 10), 0 to quit:
// 3 is OK
Enter the number of bank account ( < 10), 0 to quit:
3
Enter the start value of account number:
333
Account number: 324-001-333
Pin Code: 8435
Account number: 324-001-334
Pin Code: 6869
Account number: 324-001-335
Pin Code: 5797
Enter the number of bank account ( < 10), 0 to quit:
0
Quit ...
// there are 7 accounts in bankUSQ_account.txt now
*/
/* bankUSQ_account.txt
111
8327
112
3620
222
8350
223
7554
333
8435
334
6869
335
5797
*/