SORCE CODE:
#include <iostream>
#include <string>
#include<cstdlib>
Using namespace std;
// class
Class Bank {
Private:
Long int acno,password;
// char name[30];
String name;
Long int balance;
Public:
Int login(long int account, long int str)
{
// string pass;
//cout<<”Enter password : “;
//cin>>pass;
If(account==acno && str==password)
{
ShowAccount();
Return 1;
}
Return 0;
}
Void OpenAccount()
{
Cout << “\nEnter Name: “;
Getline(cin,name);
//cin>>name;
Cout << “Deposit Amount : “;
Cin >> balance;
If(balance >=100)
{
Cout << “Account Number: “;
Acno=(rand()%(1000000000-9999999999+1))+999999999;
Cout<<acno<<”\n”;
Cout<<”Create 6-digit password : “;
Cin>>password;
[Link]();
Cout<<”Account created !!\n “;
}
Else
{
Cout<<”Less deposit amount !!!! “;
Exit(0);
}
}
Void ShowAccount()
{
Cout<<”~~~~~~~~~~~~~~~~~~~ ACCOUNT DETAILS
~~~~~~~~~~~~~~~~~”<<endl;
Cout << “Account Number: “ << acno << endl;
Cout << “Name: “ << name << endl;
Cout << “Balance: “ << balance << endl;
}
Void Deposit()
{
Long amt;
Cout << “Enter Amount you want to deposit? “;
Cin >> amt;
Balance = balance + amt;
Cout<<”Balance : “<<balance;
}
Void Withdrawal()
{
Long amt, x;
Long int pass;
Cout<<”Enter password :”;
Cin>>pass;
// x=strcmp(pass,password);
If(pass==password)
{
Cout << “Enter Amount you want to withdraw? “;
Cin >> amt;
X=balance-amt;
If(x<100 && amt<balance || amt==balance)
Cout<<”Balance would be less than 100 “;
Else if ( amt < balance)
{
Balance = balance – amt;
Cout<<”Balance: “<<balance;
}
Else
{
Cout << “Less Balance…” << endl;
Exit(0);
}
}
Else
Cout<<”Wrong password !!! “;
}
Int Search(long int);
};
Int Bank::Search(long int a)
{
If (acno == a) {
ShowAccount();
Return (1);
}
Return (0);
}
// main code
Int main()
{
Bank C[3];
Int found = 0, p,n, ch, I;
Long int a,log;
Cout<<”**************** WELCOME TO OUR BANK
*****************\n”<<endl;
Cout<<”How many account you want store : “<<endl;
Cin>>n;
[Link]();
Cout<<”################ CREATING THE ACCOUNTS
################\n”;
For (I = 0; I < n; i++)
{
C[i].OpenAccount();
}
Cout<<”\
n___________________________________________________
___\n”;
Cout<<” \nLOGIN : \n”;
Cout << “Account Number ? “;
Cin >> a;
Cout<<”Enter 6-digit password : “;
Cin>>log;
For (I = 0; I < n; i++)
{
//found = C[i].Search(a);
// if (found)
P= C[i].login(a,log);
}
If(p==1)
{
Do
{
Cout<<”\n-------------------------------------------------------“;
// display options
Cout << “\n\n 1:Display All\n 2:By Account No\n 3:Deposit\
n 4:Withdraw\n 5:Exit” << endl;
// user input
Cout << “Please input your choice: “;
Cin >> ch;
Switch (ch)
{
Case 1: // displaying account info
For (I = 0; I < n; i++) {
C[i].ShowAccount();
}
Break;
Case 2: // searching the record
Cout << “ACCOUNT NUMBER ? “;
Cin >> a;
For (I = 0; I < n; i++) {
Found = C[i].Search(a);
If (found)
Break;
}
If (!found)
Cout << “Record Not Found” << endl;
Break;
Case 3: // deposit operation
Cout << “ACCOUNT NUMBER To Deposit Amount? “;
Cin >> a;
For (I = 0; I < n; i++)
{
Found = C[i].Search(a);
If (found)
{
C[i].Deposit();
Break;
}
}
If (!found)
{
Cout << “Record Not Found” << endl;
Exit(0);
}
Break;
Case 4: // withdraw operation
Cout << “ACCOUNT NUMBER To Withdraw Amount? “;
Cin >> a;
For (I = 0; I < n; i++)
{
Found = C[i].Search(a);
If (found)
{
C[i].Withdrawal();
Break;
}
}
If (!found)
{
Cout << “Record Not Found” << endl;
Exit(0);
}
Break;
Case 5: // exit
Cout << “Have a nice day ^_^” << endl;
Break;
Default:
Cout << “Wrong Option” << endl;
}
}while (ch != 5);
}
Else
Cout<<”Wrong password or account number “;
Return 0;
}