void withdrawl(BankAccount account[], int num_accts){
    int accountnum = 0;
    //prompt the user for an account number
    accountnum = accountNumPrompt();
    //validate that account number
    accountnum = find_acct(account, num_accts, accountnum);
    if(accountnum == -1){
        //give error if its not found
        string message = "We couldn't find an account by that number";
        error(message);
        withdrawl(account, num_accts);
    }else{
        //keep asking until you get a valid amount
        BankAccount * b = &account[accountnum];
        while(true){
            double howmuch = 0.00;
            cout << endl << "How much do you want to withdraw?" << endl;
            cin >> howmuch;
            if(b->withdraw(howmuch)){
                cout << endl << howmuch << " has been withdrawn from account: " << b->getAccountNumber() << endl;
                break;
            }else{
                cout << "Acount " << b->getAccountNumber() << " does not have sufficient funds." << endl;
                
            }
        }
    }
}
void print_accts(BankAccount account[], int num_accts){
    //create pointer variable
    BankAccount * b;
    for(int i=0; i<num_accts; i++){
        //stores our current account
        b = &account[i];
        cout << "name: " << b->getFirstName() << " " << b->getLastName() << endl;
        cout << "\t\tAccount Number: " << b->getAccountNumber() << endl;
        cout << "\t\tAccount Type: " << b->getAccountType() << endl;
        cout << "\t\tAccount Balance: " << b->getAccountBalance() << endl;
    }
}
int newAccount(BankAccount account[], int max_accounts, int num_accts){
    BankAccount * b;
    //make sure there is space left
    if(num_accts+1 <= max_accounts){
        b = &account[num_accts];
        string fname, lname, type;
        int SSN;
        double acctbalance;
        cout << endl << "Please enter first name: ";
        cin >> fname;
        cout << endl << "Please enter last name: ";
        cin >> lname;
        cout << endl << "Please enter SSN (Social Security Number): ";
        cin >> SSN;
        cout << endl << "Please enter Account Type: ";
        cin >> type;
        cout << endl << "Please enter Account starting Balance: ";
        cin >> acctbalance;
        b->setFirstName(fname);
        b->setLastName(lname);
        b->setSSN(SSN);
        //increment the account number
        int greatest = 0;
        BankAccount * g;
        for(int i=0; i < num_accts; i++){
            g = &account[i];
            if(g->getAccountNumber() > greatest){
                greatest = g->getAccountNumber();
            }
        }
        greatest++;
        b->setAccountNumber(greatest);
        b->setAccountType(type);
        b->setAccountBalance(acctbalance);
        num_accts++;
        return num_accts;
    }
void deposit(BankAccount account[], int num_accts){
    int accountnum = 0;
    accountnum = accountNumPrompt();
    accountnum = find_acct(account, num_accts, accountnum);
    if(accountnum == -1){
        string message = "We couldn't find an account by that number";
        error(message);
        deposit(account, num_accts);
    }else{
        BankAccount * b = &account[accountnum];
        double howmuch = 0.00;
        cout << endl << "How much do you want to deposit?" << endl;
        cin >> howmuch;
        b->addAccountBalance(howmuch);
        cout << endl << howmuch << " has been deposited int account: " << b->getAccountNumber() << endl;
    }
}
int find_acct(BankAccount account[], int num_accts, int request_acct){
    //creats pointer variable
    BankAccount * b;
    int num = 0;
    //bool for telling when we have found the right account
    bool found = false;
    for(int i=0; i<num_accts; i++){
        //store current account
        b = &account[i];
        if(b->getAccountNumber() == request_acct){
            //store account number when it matches the requested number
            num = i;
            found = true;
            break;
        }
    }
    if(found){
        return num;
    }else{
        return -1;
    }
}