I am having trouble with my code. I cannot seem to understand how to implement my balances into the arrays while using structures. Is there anyone that could help me?
#include <iostream>
#include <iomanip>
using namespace std;    
struct BankAccount
{
    int accountNum;
    double accountBal;
    double annualIntrest;
    int term;
};
int main()
{
    const int BANKACC = 5;
    const int QUIT = 1;
    const int MONTHS_IN_YEAR = 12;
    int x,found,input,month;
    double total = 0;
    double average = 0;
    BankAccount accounts[BANKACC];
    for(x = 0; x < BANKACC; x++)
    {
        do
        {
            found = 0;
            cout << "Enter in account # " << (x + 1) << endl;
            cin >> accounts[x].accountNum;
            while(accounts[x].accountNum < 1000 || accounts[x].accountNum > 9999)
            {
                cout << "Account number must be four didgets:" << endl;
                cin >> accounts[x].accountNum;
            }
            for(int check = 0; check < x; check++)
            {
                while(accounts[x].accountNum == accounts[check].accountNum)
                {
                    cout << endl << "Account Numbers cannot be the same, enter in a new account number." << endl;
                    found = 1;
                    break;
                }
            }
        } while(found); 
        cout << "Enter the accounts balance."  << endl;
        cin >> accounts[x].accountBal;
        while(accounts[x].accountBal < 0)
        {
            cout << "Account cannot have a negitive balance." << endl;
            cin >> accounts[x].accountBal;
        }
        cout << "Enter the interest rate." << endl;
        cin >> accounts[x].annualIntrest;
        while(accounts[x].annualIntrest > 0 && accounts[x].annualIntrest > 0.15)
        {
            cout << "Annual interest must be from 0 to 0.15." << endl;
            cin >> accounts[x].annualIntrest;
        }
        cout << "How many years will the term be held for? " << endl;
        cin >> accounts[x].term;
            while(accounts[x].term < 1 || accounts[x].term > 10)
            {
                cout << "The Term must be greater than 1 and should not exceed 10" << endl;
                cin >> accounts[x].term;
            }
    }
    for(int year = 1; year < accounts[x].term; year++)
    {
        for( month = 1; month < MONTHS_IN_YEAR; month++)
        { 
            accounts[x].accountBal = accounts[x].accountBal * accounts[x].annualIntrest + accounts[x].accountBal;
            total += accounts[x].accountBal;
            x++;
        }
        month = 1;
        average = total  / BANKACC;
    }
    for(x = 0; x < BANKACC; x++)
    {
        cout << "Account # " << (x + 1) << "'s number is: " << accounts[x].accountNum;
        cout << " The accounts balance is: " << accounts[x].accountBal;
        cout << " The interest on the account is: " << accounts[x].annualIntrest << endl;
    }
    cout << "Average of all the bank accounts is: " << average << endl;
    cout << "Which account do you want to access?" << endl <<
        " To stop or look at none of the account numbers type " << QUIT << endl;    
        for(x = 0; x < BANKACC; x++)
        {
            cout << accounts[x].accountNum << "    ";
        }
        cin >> input;
        while(input != QUIT)
        {
            found = 0;
            x = 0;
            while(x < BANKACC && input != accounts[x].accountNum)
            {
                x++;            
            }
                if(input == accounts[x].accountNum)
                {
                    cout << "Account:" << accounts[x].accountNum << " balance is: " <<
                    accounts[x].accountBal << " Interest rate is: " << accounts[x].annualIntrest;
                    cout << endl << "Enter the another account number or type 1 to quit.";
                    found = 1;
                    cin >> input;
                }
            if(found == 0)
            {
            cout << "Sorry that account doesn't exist. Enter another account number.";
            cin >> input;
            }
        }
    system("pause");
    return 0;
}
 
     
    