0% found this document useful (0 votes)
29 views13 pages

Lab Report9

The document is a lab report submitted for an Object Oriented Programming course. It includes the student's name, date of submission, and details of an experiment conducted to create a basic banking application using C++ classes. The code defines an Account class to store customer details and implement functions for depositing, withdrawing, and displaying account balances.

Uploaded by

MD RAKIBUL HAQUE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views13 pages

Lab Report9

The document is a lab report submitted for an Object Oriented Programming course. It includes the student's name, date of submission, and details of an experiment conducted to create a basic banking application using C++ classes. The code defines an Account class to store customer details and implement functions for depositing, withdrawing, and displaying account balances.

Uploaded by

MD RAKIBUL HAQUE
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Lab Report.

09
Title: Laboratory Experiment- 09

Course title: Object Oriented Programming (C++) Laboratory


Course code: CSE-160
1st Year 2nd Semester Examination 2021

Date of Submission: 04.01.2021

Submitted to-

Dr. Md. Ezharul Islam


Mohammad Ashraful Islam
Md. Musfique Anwar

Department of Computer Science and Engineering


Jahangirnagar University
Savar, Dhaka-1342

Sl Class Roll Exam Roll Name

01 373 Md. Rakibul Haque


Code:
#include<bits/stdc++.h>

using namespace std;

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:
{

cout << "Enter your account number: ";


cin >> num;
for(j = 0; j < r; j++)
{
if(num == rakib[j]->getacc_num())
{
double dep_money;
cout << "Enter the amount you wish to deposit: ";
cin >> dep_money;
rakib[j]->deposit(dep_money);
goto rakib5;
break;
}
}
}
case 3:
{

cout << "Enter your account number: ";


cin >> num;
for(j = 0; j < r; j++)
{
if(num == rakib[j]->getacc_num())
{
double with_money;
cout << "Enter the amount you want to withdraw: ";
cin >> with_money;
rakib[j]->withdraw(with_money);
goto rakib5;
break;
}
}
if(j >= r)
{
cout << "Invalid account number.\n";
goto menu1;
}
}
case 4:
{

cout << "Enter your account number: ";


cin >> num;
for(j = 0; j < r; j++)
{
if(num == rakib[j]->getacc_num())
{
cout << "Account Information:\n";
rakib[j]->display();
goto menu2;
break;
}
}
if(j >= r)
{
cout << "Invalid account number.\n";
goto menu1;
}
}
case 5:
{

cout << "Enter your account number: ";


cin >> num;
rakib5:
for(j = 0; j < r; j++)
{
if(num == rakib[j]->getacc_num())
{
cout << "Your current balance is :" << fixed << rakib[j]-
>getCurBalance() << endl;
rakib[j]->display();
goto menu2;
break;
}
}
if(j >= r)
{
cout << "Invalid account.\n";
goto menu1;
}
}
case 0: break;
};
case 0: break;
};
ofstream outfile("BankDB.DAT",ios::binary);
for( i = 0; i < r; i++)
{
outfile.write(reinterpret_cast<char*>(rakib[i]), sizeof(*rakib[i]));
}
outfile.close();

Output:

You might also like