// dear experts, i have no idea where the error is, i don't get any error messages but //after running it
// stops half way, please rectify this problem, thanks.
// there is No error in code.


#include<iostream.h>
using namespace std;

class bankacct
{
private : int acc_num ;
double bal;

public : bankacct()
{
acc_num = 20110001;
bal = 0;
}
void Newaccount(int num);
void deposit(double amount);
void withdrawal(double amount);
void print(int num, class bankacct account[5]);
};

void bankacct::Newaccount(int num)
{
cout<<"Your choice 1\n\n";
acc_num = acc_num + num;
cout<<"Result: ["<<num<<"/5 account created.\n";
cout<<"Account Number: "<<acc_num<<"\n";
cout<<"Balance: $0.00\n";
return;
}

void bankacct::deposit(double amount)
{
cout<<"Your choice: 2\n";
cout<<"Account Number: "<<acc_num<<"\n";
cout<<"Amount: "<<amount<<"\n\n";

cout<<"Result: Deposit performed\n";
cout<<"Account Number: "<<acc_num<<"\n";
cout<<"Balance: $"<<(bal = (bal + amount))<<"\n";
return;
}

void bankacct::withdrawal(double amount)
{
if(amount > bal)
{
cout<<"Withdrawal failed, withdrwal greater than account balance\n";
return;
}

cout<<"Your choice: 3\n";
cout<<"Account Number: "<<acc_num<<"\n";
cout<<"Amount: "<<amount<<"\n\n";

cout<<"Result: Withdrawal performed\n";
cout<<"Account Number: "<<acc_num<<"\n";
cout<<"Balance: $"<<(bal = (bal - amount));
return;
}

void bankacct:rint(int num, class bankacct account[5])
{
int ctr;

cout<<"Result: "<<num<<" existing accounts.\n";
for(ctr=0;ctr<num;ctr)
{
cout<<"Account number: "<<account[ctr].acc_num<<"\n";
cout<<"Balance: $"<<account[ctr].bal<<"\n\n";
}
return;
}

int main()
{
class bankacct account[5];
double amount;
int num = 20110000; // user number 0 - 4, account[num];
int operation = 0;

while((operation != 5) || (num > 4))
{
cout<<"Service available (1. New Acct, 2. Deposit, 3. Withdrawal, 4. Print All, 5. exit)\n";
cin>>operation;

if(operation == 1)
num++;

if(operation == 1)
{
account[num].Newaccount(num);
}

if(operation == 2)
{
cout<<"Enter the amount to deposit : ";
cin>>amount;
account[num].deposit(amount);
}

if(operation == 3)
{
cout<<"Enter the amount to withdraw : ";
cin>>amount;
account[num].withdrawal(amount);
}
if(operation == 4)
{
account[1].print(num,account);
}
}

if(num>4)
{
cout<<"Sorry, not more than 5 accounts in 1 attempt\n";
return 0;
}

system("pause > null");
return 0;
}