Sorce Code
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”;
}
Else
Cout<<”Wrong password !!! “;
}
Int Search(long int);
};
// main code
Int main()
{
Bank C[3];
}
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;
}