Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Overview The First National Bank of Parkland has asked you to design and develop

ID: 664806 • Letter: O

Question

Overview
The First National Bank of Parkland has asked you to design and develop an account transaction database system. The system allows bank employees to:

1) Setup an account for a new customer (make sure your system can hold at least 20 total customers). Every customer account should contain the customer first and last name, address, social security number (SS#), interest rate, and a field for the total balance in the account.

2) Assign interest rates for each of the accounts.

3) Make transactions on the accounts (deposits or withdrawals).

4) Calculate the total balance with interest for each account (balance = balance + balance*interest rate)

5) Print account information for a single customer or the entire list of customer accounts. Include in the output all information for each account (name, address, SS#, interest rate, type of account, balance) in a readable and well organized output format.


Develop a menu-driven interactive system that provides bank employees with a menu listing the various commands available and continue until the user terminates the program. An example of a typical session might look like:

jdoe@shaula % project2

----------------------------------------
Welcome to the First National Bank
of Parkland - Account transaction system
----------------------------------------

Enter any of the following commands:
        1) Create account
        2) Print accounts
        3) Select account
        4) Deposit
        5) Withdrawal
        6) Quit

Design
Develop your data models by using the design methodology discussed in the study notes. Document organized, well-written design notes that capture what each of the models "knows" and "does" in a table format (similar to designs in the study notes). With the importance of design in software development, these design tables will be handed in as part of the project submission and graded as part of the project grade. Write up your design tables in either text or Microsoft Word format files and include in your project folder submission. As discussed in lecture, object-oriented program development begins with thinking about solutions differently. An essential element to well-developed OO programs is the identification, design, and construction of robust data models to reflect the program specification. From the project description, identify, design, and develop at least 2 new classes for this project to receive full credit. Design and develop your C++ classes to accurately represent the data models and the tasks operating on the data models. As in the study notes, put each class definition in its own header file (.h), each class member function definitions in its own source file (.C), and the program application in its own source file (project2.C).

Explanation / Answer

                                                     /* This program simulates a bank. It includes functions such as withdrawal, deposit, create a new account, close an account, print balance, and more.

*/

#include <iostream.h>
#include <fstream.h>
#include <string.h>
//using namespace std;


struct BankAccount {
string firstname[], lastname, ssn, type;
//string lastname;
//string ssn;
int acctnum;
//string type;
double balance;
};

const int MAX_NUM = 100;
BankAccount account[MAX_NUM];
int max_accts, num_accts;

int read_accts(BankAccount account[], int max_accts);
void menu();
int findacct(const BankAccount account[], int num_accts, int requested_account);
void withdrawal (BankAccount account[],   int num_accts);
void deposit (BankAccount account[],   int num_accts);
int new_acct( BankAccount account[],   int num_accts);
int close_acct(BankAccount account[], int num_accts);
void account_info(const BankAccount account[], int num_accts);
void balance (const BankAccount account[],   int num_accts);
void print_accts(const BankAccount account[],   int num_accts);

int main()
{
int num_accts = read_accts(account, max_accts);
cout<<endl<<endl;

print_accts(account,num_accts);

char ans;
while(ans!='q'){
    menu();
    cin>>ans;
switch(ans){

case 'w':
withdrawal (account,num_accts);

break;
case 'd':
deposit(account, num_accts);

break;
case 'n':
num_accts = new_acct(account, num_accts);

break;
case 'b':
balance (account, num_accts);

break;

case 'i':
account_info(account,num_accts);

break;

case 'c':

num_accts = close_acct(account, num_accts);

break;

case 'q':
cout<<"Thank you please come again.";
break;

default:

    cout<<"Please make a valid selection from the menu.";
    cin>>ans;

break;

}

}//end of while ans != q loop


    return 0;
}

int read_accts( BankAccount account[], int max_accts)
//reads in account numbers and balances into arrays and returns the number read in. max_accts is max amount allowed in.
{
int n;

for (int p=0; p<max_accts; p++){

n=p;}
cout<<"Finished reading in all accounts."<<endl;


return n;

}


void menu(){
    cout<<endl<<endl;
cout<<"Select one of the following:"<<endl<<endl;
cout<<' '<< "W - Withdrawal"<<endl;
cout<<' '<< "D - Deposit"<<endl;
cout<<' '<< "N - New account"<<endl;
cout<<' '<< "B - Balance"<<endl;
cout<<' '<< "I - Account Info" <<endl;
cout<<' '<< "C - Close Account" <<endl;
cout<<' '<< "Q - Quit"<<endl;
}

int findacct(const BankAccount account[], int num_accts, int requested_account)
//returns the index of account in account array if it exists, and -1 if it doesn't.
{
for (int i=0; i<num_accts; i++)
if (account[i].acctnum==requested_account)
    return i;

return -1;

}
void withdrawal ( BankAccount account[], int num_accts)
//prompts user for acctnumber. if it doesn't exist, it prints an error msg.
//otherwise, asks user for amount of withdrawal.
//if account does not contain sufficient funds, prints error msg and doesn't
//perform transaction
{ double withdrawalsize;
    int account_num, index;
   cout<<"Please enter your account number: ";
   cin>>account_num;
   index=findacct(account, num_accts, account_num);
   if (index<0){
   cout<<"That account does not exist. Exiting.";
   }
   else{
   cout<<"How much would you like to withdrawal?"<<endl;
   cin>>withdrawalsize;
    if (withdrawalsize>account[index].balance)
    cout<<"Insufficient Funds.";
    else{
    account[index].balance-=withdrawalsize;
    cout<<"Here is your "<<withdrawalsize<<" dollars."<<endl;
    cout<<"Your current balance is now "<< account[index].balance<<endl;
    }
   }


}


void deposit (BankAccount account[], int num_accts)
//prompts user for acct number. if does not exist, print error msg.
//otherwise, asks user for amount of deposit.
{
    int account_num, index;
    double depositsize;
   cout<<"Please enter your account number: ";
   cin>>account_num;
   index=findacct(account, num_accts, account_num);
   if (index<0){
   cout<<"That account does not exist.";
   }
   else
   cout<<"How much would you like to deposit?"<<endl;
   cin>>depositsize;
   account[index].balance+=depositsize;
   cout<<"Your current balance size is "<<account[index].balance<<endl;
}
int new_acct( BankAccount account[], int num_accts)
//prompt user for new acct number. if account already exists, print errormsg.
//Otherwise, add account to account array with an initial balance of 0.
//Returns the new number of accounts(total in system).
{
    int account_num;
    int index;
   cout<<"Please enter your new account number: ";
   cin>>account_num;
   index=findacct(account, num_accts, account_num);
   if (index >= 0)
   cout<<"That account already exists.";
   else {
   account[num_accts].acctnum = account_num;
   account[num_accts].balance=0;
   cout<<"Your new account number is "<<account_num<<" and your current balance is 0."<<endl;
   num_accts+=1;}
   return num_accts;

}
void balance (const BankAccount account[], int num_accts)
//Prompts user for account number. If doesn't exist, error msg.
//Otherwise, print account balance.
{
    int index;
    int account_num;
    cout<<"Please enter your account number: ";
    cin>>account_num;
    index=findacct(account, num_accts, account_num);
    if (index<0){
    cout<<"That account does not exist. Exiting.";
   }
   else
   cout<<"Your current balance is "<< account[index].balance<<"."<<endl;
}
void print_accts(const BankAccount account[], int num_accts)
//Prints all customer information
//account number and balance
{

    cout<<"Account Number Balance"<<endl;
    for (int i=0; i<num_accts; i++)
    {
        cout<<account[i].acctnum<<' '<<account[i].balance<<account[i].type<<endl;

    }
}

int close_acct(BankAccount account[], int num_accts)
{
    cout<<"Please enter account number: ";
    int account_num;
    cin>>account_num;
    int index;
    index=findacct(account, num_accts, account_num);
    if (index<0)
        cout<<"Account does not exist. Exiting."<<endl;
    else
        {
            cout<<"Closing the account."<<endl;
                if(num_accts==1)
                    num_accts--;
                else{
            for (int i = index; i<num_accts-1; ++i)
                {
                    account[i] = account[i+1];
                }
                num_accts--;
                }

        }


return num_accts;
}
void account_info(const BankAccount account[], int num_accts)
{
    string ssn;
    bool foundflag = false;
    cout<<"Please enter your social security number:";
    cin>> ssn;
    for (int i = 0; i<num_accts;i++)
        if(account[i].ssn == ssn)
        {
            cout<<"Account information:"<<endl;
            cout<<"Name: "<< account[i].firstname<<" "<<account[i].lastname<<endl;
            cout<<"Account Number: "<<account[i].acctnum<<endl;
            cout<<"Balance: "<<account[i].balance;

            foundflag = true;
        }

    if (foundflag == false)
        cout<<"Error: account not found."<<endl;
}