0% found this document useful (0 votes)
26 views9 pages

Oop Project of 221740, 46,13,19

This document contains the source code and flow chart for a C++ console application that implements a basic bank management system. The system allows users to create bank accounts, deposit and withdraw funds, check balances, view all accounts, close accounts, and modify account details. The source code defines BankAccount and BankManagementSystem classes to model accounts and the overall system. The main function implements a menu-driven interface for users to interact with the system functionality.

Uploaded by

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

Oop Project of 221740, 46,13,19

This document contains the source code and flow chart for a C++ console application that implements a basic bank management system. The system allows users to create bank accounts, deposit and withdraw funds, check balances, view all accounts, close accounts, and modify account details. The source code defines BankAccount and BankManagementSystem classes to model accounts and the overall system. The main function implements a menu-driven interface for users to interact with the system functionality.

Uploaded by

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

OOP Semester Project

Submitted To:
Prof. Sami Ullah
Submitted By:
Barra Fatima 221740
Mian Hamad Saeed 221746
Huzaifa Akhtar 221713
Rana Zaid 221719

3rd Semester
Department of Computer Science
Topic:
Bank Management System
Source Code:
#include <iostream>
#include <vector>
#include <string>

using namespace std;

class BankAccount {
public:
int accountNumber;
string accountHolder;
double balance;

// Constructor
BankAccount(int accNumber, const string& accHolder, double initialBalance)
: accountNumber(accNumber), accountHolder(accHolder), balance(initialBalance) {}

// Member functions
void deposit(double amount) {
balance += amount;
cout << "Amount deposited successfully!" << endl;
}

void withdraw(double amount) {


if (amount <= balance) {
balance -= amount;
cout << "Amount withdrawn successfully!" << endl;
} else {
cout << "Insufficient balance!" << endl;
}
}

void displayBalance() const {


cout << "Account Holder: " << accountHolder << endl;
cout << "Account Balance: " << balance << endl;
}

void displayAccountDetails() const {


cout << accountNumber << "\t\t" << accountHolder << "\t\t" << balance << endl;
}
};

class BankManagementSystem {
private:
vector<BankAccount> accounts;

public:
int getAccountIndex(int accountNumber) {
for (int i = 0; i < accounts.size(); ++i) {
if (accounts[i].accountNumber == accountNumber) {
return i;
}
}
return -1;
}

void createAccount() {
int accNumber;
string accHolder;
double initialBalance;

cout << "Enter account number: ";


cin >> accNumber;
cout << "Enter account holder name: ";
cin.ignore();
getline(cin, accHolder);
cout << "Enter initial balance: ";
cin >> initialBalance;

BankAccount newAccount(accNumber, accHolder, initialBalance);


accounts.push_back(newAccount);
cout << "Account created successfully!" << endl;
}

void performTransaction(const string& action) {


int accountNumber;
double amount;

cout << "Enter account number: ";


cin >> accountNumber;
int accountIndex = getAccountIndex(accountNumber);

if (accountIndex != -1) {
cout << "Enter amount to " << action << ": ";
cin >> amount;

if (action == "deposit") {
accounts[accountIndex].deposit(amount);
} else if (action == "withdraw") {
accounts[accountIndex].withdraw(amount);
}
} else {
cout << "Account not found!" << endl;
}
}
void balanceInquiry() {
int accountNumber;

cout << "Enter account number: ";


cin >> accountNumber;
int accountIndex = getAccountIndex(accountNumber);

if (accountIndex != -1) {
accounts[accountIndex].displayBalance();
} else {
cout << "Account not found!" << endl;
}
}

void accountHolderList() {
cout << "----- Account Holder List -----" << endl;
cout << "Account No.\tAccount Holder\tBalance" << endl;

for (int i = 0; i < accounts.size(); ++i) {


accounts[i].displayAccountDetails();
}

cout << "--------------------------------" << endl;


}

void closeAccount() {
int accountNumber;

cout << "Enter account number: ";


cin >> accountNumber;
int accountIndex = getAccountIndex(accountNumber);

if (accountIndex != -1) {
accounts.erase(accounts.begin() + accountIndex);
cout << "Account closed successfully!" << endl;
} else {
cout << "Account not found!" << endl;
}
}

void modifyAccount() {
int accountNumber;

cout << "Enter account number: ";


cin >> accountNumber;
int accountIndex = getAccountIndex(accountNumber);

if (accountIndex != -1) {
cout << "Enter new account holder name: ";
cin.ignore();
getline(cin, accounts[accountIndex].accountHolder);
cout << "Account modified successfully!" << endl;
} else {
cout << "Account not found!" << endl;
}
}
};
int main() {
BankManagementSystem bankSystem;

int choice;

while (true) {
cout << "----- Bank Management System -----" << endl;
cout << "1. New Account" << endl;
cout << "2. Deposit Amount" << endl;
cout << "3. Withdraw Amount" << endl;
cout << "4. Balance Inquiry" << endl;
cout << "5. All Account Holder List" << endl;
cout << "6. Close an Account" << endl;
cout << "7. Modify an Account" << endl;
cout << "8. Exit" << endl;
cout << "Enter your choice: ";
cin >> choice;

switch (choice) {
case 1:
bankSystem.createAccount();
break;
case 2:
bankSystem.performTransaction("deposit");
break;
case 3:
bankSystem.performTransaction("withdraw");
break;
case 4:
bankSystem.balanceInquiry();
break;
case 5:
bankSystem.accountHolderList();
break;
case 6:
bankSystem.closeAccount();
break;
case 7:
bankSystem.modifyAccount();
break;
case 8:
cout << "Exiting... Thank you!" << endl;
return 0;
default:
cout << "Invalid choice! Please try again." << endl;
}

cout << endl << endl << endl;


}
}
Flow Chart:

START

WHILE
TR

TRUE

CHOICE

CASE 1 createAccount() BREAK

CASE 2
performTransaction
BREAK
("deposit")

performTransaction BREAK
CASE 3
("withdraw")

CASE 5 accountHolderList() BREAK


CASE 4 balanceInquiry() BREAK

CASE 6 closeAccount() BREAK

CASE 7 modifyAccount() BREAK

CASE 8 return 0 BREAK END


INVALID
DEFAULT
CHOICE

You might also like