Professional Documents
Culture Documents
PROJECT REPORT
ON
SUBMITTED TO
DIPLOMA IN
COMPUTER ENGINEERING
UNDER GUIDENCE OF
MISS. MESHRAM S.P.
DEPARTMENT of Computer
A.C.S.’S
DIPLOMA IN ENGINEERING AND TECHNOLOGY, ASHTI
(2022-2023)
A.C.S.’S
CERTIFICATE
This is to Certify that the project report entitled
“Bank Management System”
Submitted by
1. Mr. Solaskar Pradip Balu 2215020044
2. Mr. Manmode Aniruddha Badrinath 2215020052
3. Mr. Kathle Tejas Babasaheb 2215020036
In The Academic Year 2022-2023 In The Partial Fulfilment Of third Semester Diploma in Computer
Engineering. It Is Certified That All Suggestion Indicated For Internal Assessment Have Been Incorporated In
Report. The Project Has Been Approved As It Satisfies The Academic Requirement In Respect Work Prescribed For
The Said Degree
1. Introduction
1. C++ compiler
2. Command Prompt or Terminal to run the program
Technical Requirements
1. Knowledge of C++ OOP principles and classes
Project Requirements
1. File handling: reading and writing data to a file will be utilized to save
account login data.
2. Banking functionality: deposits, withdrawals, and other banking operations
to be performed by the user.
3. User input/output: input will be gathered for account creation and navigation
of the banking program. Output in terminal will be used to display
instructions to the user or account data.
1. Database: responsible for saving and loading user data from a text file.
Overall, this class will help manage user data and functions involving data
access such as user login, user creation, and user deletion.
Program Design
Each class represents and organizes the different responsibilities within
the banking system. Through keeping an organized structure, the code can be
easily updated and maintained. All user and manager account data are stored in
users.txt and managers.txt respectively while both UserManager and BankManager
provide login abilities for these accounts. The main function takes care of user
interactions and ensures all users can easily access and use their bank account to
perform their banking needs.
For our users and their banking data to be stored, we will define a
database class that takes care of all operations involving saving and loading data
from a file, user login, and the creation and deletion of users. Our file users.txt will
store all users who have opened an account and their corresponding password.
Because their login data will be saved in the system, they can log back in at any
time :
class Database {
public:
Database() {
loadUsersFromFile();
loadManagersFromFile();
}
bool loadUsersFromFile() {
ifstream userFile("users.txt");
if (!userFile) {
return false;
}
string line;
while (getline(userFile, line)) {
istringstream iss(line);
string username, password;
if (iss >> username >> password) {
users[username].first = password;
}
}
userFile.close();
return true;
}
bool loadManagersFromFile() {
ifstream managerFile("managers.txt");
if (!managerFile) {
string line;
while (getline(managerFile, line)) {
istringstream iss(line);
string username, password;
if (iss >> username >> password) {
managers[username] = password;
}
}
managerFile.close();
return true;
}
bool login() {
string username, password;
cout << "Enter username: ";
cin >> username;
if (users.find(username) != users.end()) {
cout << "Enter password: ";
cin >> password;
if (users[username].first == password) {
return true;
}
}
cout << "Incorrect username or password. Try again." << endl;
return false;
}
private:
unordered_map<string, pair<string, double>> users;
unordered_map<string, string> managers;
};
class Transaction {
public:
string type; // Type of transaction
double amount; // Amount transacted
class BankAccount {
public:
BankAccount(const string &username, Database &db) : username(username), open(true),
balance(0), database(db) {
// Read account balance from file users.txt
ifstream file("users.txt");
string line;
while(getline(file, line)) {
istringstream iss(line);
string storedUsername , storedPassword;
double storedBalance;
if (iss >> storedUsername >> storedPassword >> storedBalance) {
if (storedUsername == username) {
balance = storedBalance;
break;
}
}
}
}
void PrintAccountSummary() {
cout << "Account Holder: " << username << endl;
cout << "Balance: $" << balance << endl;
cout << "Transactions:" << endl;
for (const Transaction &transaction : transactions) {
cout << transaction.type << ", Amount: $" << transaction.amount << endl;
}
cout << " " << endl;
}
void updateBalanceInFile() {
ifstream inputFile("users.txt");
ofstream outputFile("temp.txt");
string line;
while (getline(inputFile, line)) {
istringstream iss(line);
string storedUsername, storedPassword;
double storedBalance;
inputFile.close();
outputFile.close();
remove("users.txt");
rename("temp.txt", "users.txt");
}
private:
string username;
bool open;
double balance;
vector<Transaction> transactions;
Database &database;
};
If an existing user logs in, their account balance from previous transactions will be
read and retrieved from 'users.txt'. Otherwise, their balance is initialized as 0.
Each time a user performs a banking transaction, their balance within 'users.txt' is
updated with updateBalanceInFile.
Withdraw removes a specified amount of funds from the user's account given that
they have enough money to do so.
Deposit allows the user to add a specified amount of money to their account. The
amount is added to their total account balance if their account is currently open.
Otherwise, the user is notified of the error.
CloseAccount closes a created account if desired by the user and deletes their
login data from the database.
To complete our banking simulation, we must ensure that the user can
choose between different banking and account options. To do so, we will display
these choices as a list and prompt the user to enter the number corresponding with
the choice they'd like to make:
int main() {
Database database;
BankManager manager;
string username, password;
BankAccount acc("", database);
int choice;
int bankingOption;
double withdrawAmt;
double depositAmt;
bool loggedIn = false;
bool managerLoggedIn = false;
while (true) {
if (!loggedIn) {
cout << "1. Login\n2. Create Account\n3. Manager Login\n4. Exit\n";
cin >> choice;
if (choice == 1) {
if (database.login()) {
loggedIn = true;
username = username;
acc.setUsername(username);
}
} else if (choice == 2) {
string newUsername , password;
cout << "Enter new username: ";
cin >> newUsername;
cout << "Enter password: ";
cin >> password;
database.createUser(newUsername, password);
username = newUsername;
To move forward with testing our implementation, we must enter the number
corresponding to the choice we want to make. In this case, we would like to create
an account since we have yet to make one. Type 2 into the terminal and press
enter.
Next, it will prompt you to enter a new username. This can be any name of your
choice! Once that is complete, enter a password to complete your account creation.
First we are going to Deposit some amount in bank account, and then going to
Withdraw some amount.
Deposit :
Withdraw