Question
Description For this assignment, you will maintain an array of bank accounts. You will declare a struct type called bankAcct and have an array of
Description For this assignment, you will maintain an array of bank accounts. You will declare a struct type called bankAcct and have an array of bankAcct with maximum size of 20, the members of the struct are shown below struct
bankAcct { string first , last ; double amount ; long acctNo ; short pin ; };
Each member is described below
string first stores the users first name string last stores the users last name
double amount stores the users current balance
long acctNo stores the users 7 digit bank account number
short pin stores the users 4 digit PIN A text file will be given, and your program will read the text file and populate the array of bankAcct objects.
The number of lines will be no greater than 20. Each line will contain the following data in the following order: FirstName LastName BankAccount PIN Balance. Each line will be terminated by an end of line character. You will need to write the following functions
int storeInfo(bankAcct[], ifstream&) - this function takes in the array of bank accounts and an input file stream variable, this will read through the file and populate the array and returns an integer denoting the amount of bank accounts read from the file
void sort(bankAcct[], int) - this function will sort the array of bank accounts with respect to their account numbers, the integer passed in is the amount of accounts (the value returned from the storeInfo function) 1
int search(bankAcct[], int, long) - this function takes in the array of bank accounts, the amount of bank accounts, and the bank account number to search for (in the array of bank accounts), an integer is returned which is the index of the bankAcct array whose account number matches the long parameter, if no such account exists, then a -1 is returned, this function will perform a binary search.
void outputAndHandleRequest(bankAcct&) - this function takes in an account object (found using the search function), and it will output the bank account info (last name, first name, account number and current balance), you may need to use output manipulators for this, and then it will ask the user whether they want to deposit or withdraw, then will ask for an amount and will update the account accordingly
You cannot modify the function return types or the parameters, you need to design your main with these functions in mind, so for example, you need to sort the array before you can perform binary search. Another tip to get you started, user is prompted for the bank account number in main, then call the search function to get an index and based on the index returned you call the output function by passing in the object located the index retrieved from search (if it is not -1)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access with AI-Powered Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started