This is my Code
#include<iostream>
using namespace std;
struct BankAccount
{
int accountNum;
double accountBal;
double rate;
};
int main()
{
const int ACCOUNT = 5;
BankAccount info[ACCOUNT];
int sub;
double balTotal = 0;
double balAverage;
int accountNumber;
bool isFound = false;
for(sub =0; sub<ACCOUNT ; ++sub)
{
cout<<"Enter Account Number: ";
cin>>info[sub].accountNum;
cout<<"Enter Account Balance: ";
cin>>info[sub].accountBal;
cout<<"Enter Interest rate: ";
cin>>info[sub].rate;
}
for(sub=0; sub<ACCOUNT ; ++sub)
{
balTotal +=info[sub].accountBal;
++sub;
balAverage = balTotal/ACCOUNT;
}
for(sub=0; sub<ACCOUNT ; ++sub)
{
cout <<"Account Number";
cout<<info[sub].accountNum<<endl;
cout <<"Account Balnce";
cout<<info[sub].accountBal<<endl;
cout<<"Account Rate";
cout<<info[sub].rate<<endl;
}
cout<<"Total Account Balance"<<balTotal<<endl;
cout<<"Average for Account Balance"<<balAverage<<endl;
cout<<"Enter Account Number";
cin>>accountNumber;
for(sub = 0; sub < ACCOUNT; ++ sub)
if(accountNumber == info[sub].accountNum)
{
cout<<"Account Information :" <<endl;
cout<<info[sub].accountNum<<endl;
cout<<info[sub].accountBal<<endl;
cout<<info[sub].rate<<endl;
isFound = true;
}
if(isFound == false)
cout<<"invalid Account "<<endl;
system("pause");
return 0;
}
I want to be able to loop the invalid part of the program, they use can re-enter the Account number if is invalid , Help please