Lab Report9
Lab Report9
09
Title: Laboratory Experiment- 09
Submitted to-
class Account
{
private:
int Acc_number;
char name[1001],phone[1001],NID[1001];
double balance;
public:
Account()
{
Acc_number = 0;
strcpy(name,"\0");
balance = 0;
strcpy(phone,"\0");
strcpy(NID,"\0");
}
Account(int a, char n[],double d,char p[],char nid[])
{
Acc_number = a;
strcpy(name,n);
balance = d;
strcpy(phone,p);
strcpy(NID,nid);
}
void input()
{
cout << "Enter Account number: ";
cin >> Acc_number;
cin.ignore();
cout << "Enter Name: ";
cin >> name;
cout << "Enter Balance: ";
cin >> balance;
cin.ignore();
cout << "Enter Phone number: ";
cin >> phone;
cout << "Enter NID: ";
cin >> NID;
}
void display()
{
cout << "Account number: " << Acc_number << endl;
cout << "Name: " << name << endl;
cout << "Balance: " << fixed << balance << endl;
cout << "Phone number: " << phone << endl;
cout << "NID: " << NID << endl;
}
int getacc_num()
{
return Acc_number;
}
void deposit(double d)
{
balance += d;
}
void withdraw(double w)
{
balance -= w;
}
double getCurBalance()
{
return balance;
}
};
int main()
{
ifstream infile("BankDB.DAT",ios::binary);
int choice,i,j,num,choice2;
infile.seekg(0,ios::end);
int r = (infile.tellg()) / sizeof(Account);
Account *rakib[100];
Account dummy;
infile.seekg(0);
for( i = 0; i < r; i++)
{
rakib[i] = new Account;
infile.read(reinterpret_cast<char*>(rakib[i]), sizeof(*rakib[i]));
}
infile.close();
menu1:
cout<<"++++++Welcome to Rakib bank BD++++++"<<endl;
cout << "1.create account \n";
cout<<"2.open your account"<<endl;
cout << "0. Exit.\n";
cout << "Enter your choice : ";
cin >> choice;
switch(choice)
{
case 1:
{
rakib1:
rakib[i] = new Account;
rakib[i]->input();
r++;
cout<<"you created account Rakib Bd Bank"<<endl;
goto menu1;
}
case 2:
menu2:
cout<<"++++++Rakib bank BD++++++"<<endl;
cout << "0. Exit.\n";
cout<< "1.Go to main menu \n";
cout << "2.Deposit to your account \n";
cout << "3.Withdraw from your account \n";
cout << "4.Display your account information \n";
cout << "5.Display your current balance \n";
cout << "Enter your choice : ";
cin>>choice2;
switch(choice2)
{
case 1: goto menu1;
case 2:
{
Output: