0% found this document useful (0 votes)
10 views

Bankcppcode

Uploaded by

dasbidyendu22
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Bankcppcode

Uploaded by

dasbidyendu22
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

#include <iostream>

#include <string>
using namespace std;

class Bank
{

private:
float balance;
long accountnumber;
string accountholder;
int pin;
bool isValidAccount = false;

public:
Bank()
{
this->balance = 0.f;
this->accountnumber = 0;
this->accountholder = "unknown";
this->pin = 0000;
}

void makeAccount(string holdername, int dob)


{
cout << "Your Account has been successfully created : "
<< " Your PIN is your Date of birth without punctuations , please
remember the pin . " << endl;
this->accountholder = holdername;
this->pin = dob;
this->accountnumber = 100000009 + dob * 10;
cout << "Your Accountnumber is : " << accountnumber << endl;
isValidAccount = true;
}
void makeDeposit(float depositAmount, int userPIN)
{
if (isValidAccount == true)
{
if (userPIN == pin)
{
cout << "You Have Deposited " << depositAmount << " succesfully
into you account ending with " << pin * 10 << endl;
cout << "Thank You For your Interaction with our Bank . " << endl;
this->balance += depositAmount;
}
else
{
cout << "Incorrect PIN" << endl;
}
}
else
{
cout << "Please Create an Account" << endl;
}
}
void checkBalance(int ano, int userPIN)
{
if (ano == accountnumber && userPIN == pin)
{
cout << "The Account Balance is : " << this->balance << endl;
}
}
void checkAccountWithdrawal(long ano, int userPIN)
{
if (ano == accountnumber && userPIN == pin)
{
cout << "Your Balance is : " << this->balance;
cout << endl;

cout << "Please enter withdrawal amount : ";


int withdrawAmt;
cin >> withdrawAmt;
if (withdrawAmt < 0 || withdrawAmt > this->balance)
{
cout << "Please Enter Valid Amount";
}
else
{
this->balance -= withdrawAmt;
cout << withdrawAmt << " has been deducted from your account .";
cout << endl;
cout << "Thank you for your transaction! " << endl;
}
}
else
{
cout << "Enter Valid Credentials" << endl;
}
}
};
int main()
{
cout << " Welcome To our Bank ! " << endl;
cout << "Please Select From the options below :" << endl;
cout << endl;
cout << endl;
cout << "1. Make Account " << endl;
cout << "2. Make Deposit " << endl;
cout << "3. Check Balance " << endl;
cout << "4. Withdrawal " << endl;
cout << endl;
cout << "5.Exit the Process" << endl;
cout << endl;
cout << endl;
cout << "Please Enter the number assigned to the above functions you want to
access : ";
int sn;
cin >> sn;
cout << endl;
string hname;
// float damnt;
int upin;
int uacc;
Bank Account1;

if (sn == 1)
{
cout << "Thank You For Choosing our BANK " << endl;
cout << "Please Enter Holder's Name : ";
cin >> hname;
cout << endl;
cout << "Please Enter you Date of birth without punctuatuions : ";
cin >> upin;
cout << endl;
Account1.makeAccount(hname, upin);
}
if (sn == 2)
{
cout << "Please Enter Account details : ";
cout << endl;
cout << "Enter Account No : ";
cin >> uacc;
cout << endl;
cout << "Enter PIN :";
cin >> upin;
Account1.checkAccountWithdrawal(uacc, upin);
}

return 0;
}

You might also like