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

Front C+++++++ Merged

Uploaded by

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

Front C+++++++ Merged

Uploaded by

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

BANGALORE INSTITUTE OF TECHNOLOGY

K. R. Road, V. V. Pura, Bengaluru – 560004

2023-2024

DEPARTMENT OF ELECTRICAL AND ELECTRONICS ENGINEERING

ASSIGNMENT PROJECT
on
“Define a class called Bank with all data members like customer name, address,
phone no., nominee, account nos., no. of accounts and their types, balance
amount in each of them. Define constructors, display functions and other member
functions to perform operations like updating customer data, debit and credit
transactions, search for a record given customer name/account no./phone no.”

Submitted in the partial fulfillment for the award of the degree of

BACHELOR OF ENGINEERING
in
ELECTRICAL AND ELECTRONICS ENGINEERING
Under the Guidance of
Dr .G .Sudha
Associate Professor and Head
Dept. of Electrical and Electronics Engineering

Submitted by
ADITYA PATEL 1BI23EE001
ANTAREEP SHARMA 1BI23EE006
KAILASH S 1BI23EE024
RISHI DRABLA 1BI23EE045
//PROBLEM STATEMENT

Define a class called Bank with all data members


like customer name, address, phone no., nominee,
account nos., no. of accounts and their types,
balance amount in each of them. Define
constructors, display functions and other member
functions to perform operations like updating
customer data, debit and credit transactions, search
for a record given customer name/account
no./phone no.
//SOURCE CODE
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>
class Account {
public:
int accountNo;
std::string accountType;
double balance;
Account(int accNo, const std::string& accType, double bal)
: accountNo(accNo), accountType(accType), balance(bal) {}
};
class Bank {
private:
std::string customerName;
std::string address;
std::string phoneNo;
std::string nominee;
std::vector<Account> accounts;
public:
// Constructor
Bank(const std::string& name, const std::string& addr, const std::string& phone, const
std::string& nom)
: customerName(name), address(addr), phoneNo(phone), nominee(nom) {}
// Function to display customer data
void displayCustomerData() const {
std::cout << "---------------------------------\n";
std::cout << "Customer Information\n";
std::cout << "---------------------------------\n";
std::cout << "Customer Name : " << customerName << "\n";
std::cout << "Address : " << address << "\n";
std::cout << "Phone No. : " << phoneNo << "\n";
std::cout << "Nominee : " << nominee << "\n";
std::cout << "---------------------------------\n";
std::cout << "Accounts:\n";
for (const auto& acc : accounts) {
std::cout << "Account No. : " << acc.accountNo
<< ", Type : " << acc.accountType
<< ", Balance : $" << std::fixed << std::setprecision(2) << acc.balance <<
"\n";
}
std::cout << "---------------------------------\n";
}
// Function to update customer data
void updateCustomerData(const std::string& name, const std::string& addr, const
std::string& phone, const std::string& nom) {
customerName = name;
address = addr;
phoneNo = phone;
nominee = nom;
}
// Function to add an account
void addAccount(int accNo, const std::string& accType, double balance) {
accounts.push_back(Account(accNo, accType, balance));
}
// Function to debit amount
void debit(int accNo, double amount) {
for (auto& acc : accounts) {
if (acc.accountNo == accNo) {
if (acc.balance >= amount) {
acc.balance -= amount;
std::cout << "Debited $" << amount << " from account " << accNo << ".
New balance: $" << acc.balance << "\n";
} else {
std::cout << "Insufficient balance in account " << accNo << ".\n";
}
return;
}
}
std::cout << "Account " << accNo << " not found.\n";
}
// Function to credit amount
void credit(int accNo, double amount) {
for (auto& acc : accounts) {
if (acc.accountNo == accNo) {
acc.balance += amount;
std::cout << "Credited $" << amount << " to account " << accNo << ". New
balance: $" << acc.balance << "\n";
return;
}
}
std::cout << "Account " << accNo << " not found.\n";
}
// Function to search by customer name
bool searchByCustomerName(const std::string& name) const {
return customerName == name;
}
// Function to search by account number
bool searchByAccountNo(int accNo) const {
for (const auto& acc : accounts) {
if (acc.accountNo == accNo) {
return true;
}
}
return false;
}

// Function to search by phone number


bool searchByPhoneNo(const std::string& phone) const {
return phoneNo == phone;
}
};
void updateCustomerData(Bank& customer) {
std::string name, address, phone, nominee;
std::cout << "Enter new customer name: ";
std::getline(std::cin, name);
std::cout << "Enter new address: ";
std::getline(std::cin, address);
std::cout << "Enter new phone number: ";
std::getline(std::cin, phone);
std::cout << "Enter new nominee: ";
std::getline(std::cin, nominee);
customer.updateCustomerData(name, address, phone, nominee);
std::cout << "Customer data updated successfully.\n";
}
void performTransactions(Bank& customer) {
int choice, accNo;
double amount;
while (true) {
std::cout << "Select transaction type: 1. Debit 2. Credit 3. Exit: ";
std::cin >> choice;
if (choice == 3) break;
std::cout << "Enter account number: ";
std::cin >> accNo;
if (choice == 1) {
std::cout << "Enter amount to debit: ";
std::cin >> amount;
customer.debit(accNo, amount);
} else if (choice == 2) {
std::cout << "Enter amount to credit: ";
std::cin >> amount;
customer.credit(accNo, amount);
} else {
std::cout << "Invalid choice.\n";
}
}
}
int main() {
// Creating a Bank object
Bank customer("John Doe", "123 Elm Street", "555-1234", "Jane Doe");
// Adding accounts
customer.addAccount(1001, "Savings", 1500.00);
customer.addAccount(1002, "Checking", 2500.00);
// Display customer data
customer.displayCustomerData();
// Update customer data
updateCustomerData(customer);
// Perform some transactions
performTransactions(customer);
// Display customer data again
customer.displayCustomerData();
// Search for a record
std::string searchName, searchPhone;
int searchAccNo;
std::cout << "Enter customer name to search: ";
std::cin.ignore(); // To ignore the newline character left by previous input
std::getline(std::cin, searchName);
std::cout << "Searching for customer with name '" << searchName << "': " <<
(customer.searchByCustomerName(searchName) ? "Found" : "Not Found") << "\n";
std::cout << "Enter account number to search: ";
std::cin >> searchAccNo;
std::cout << "Searching for account number " << searchAccNo << ": " <<
(customer.searchByAccountNo(searchAccNo) ? "Found" : "Not Found") << "\n";
std::cout << "Enter phone number to search: ";
std::cin.ignore(); // To ignore the newline character left by previous input
std::getline(std::cin, searchPhone);
std::cout << "Searching for phone number '" << searchPhone << "': " <<
(customer.searchByPhoneNo(searchPhone) ? "Found" : "Not Found") << "\n";
return 0;
}
//OUTPUT
Customer Information
---------------------------------
Customer Name : John Doe
Address : 123 Elm Street
Phone No. : 555-1234
Nominee : Jane Doe
---------------------------------
Accounts:
Account No. : 1001, Type : Savings, Balance : $1500.00
Account No. : 1002, Type : Checking, Balance : $2500.00
---------------------------------
Enter new customer name: kailash
Enter new address: bangalore
Enter new phone number: 100
Enter new nominee: rishi
Customer data updated successfully.
Select transaction type: 1. Debit 2. Credit 3. Exit: 3
---------------------------------
Customer Information
---------------------------------
Customer Name : kailash
Address : bangalore
Phone No. : 100
Nominee : rishi
---------------------------------
Accounts:
Account No. : 1001, Type : Savings, Balance : $1500.00
Account No. : 1002, Type : Checking, Balance : $2500.00
---------------------------------
Program overview

The program simulates a basic banking system where customers can be added
with their personal details and multiple accounts Each account can perform
transactions like credit (deposit) and debit (withdrawal) Customers and their
account details can be displayed, and searches can be performed based on
customer name, phone number, or account number

Program Components

1 Data Structures:

Bank Structure: Represents the collection of customers (`Customer` structures)

Customer Structure: Holds details such as name, address, phone number, date
of birth, email, identification type, number of accounts, and an array of `Account`
structures

Account Structure: Contains attributes like account number, account type


(enum), balance, and interest rate

2 Functionality:

Initialization (`initializeBank`): Initializes the `Bank` structure with zero


customers

Adding Customers (`addCustomer`): Allows adding a new customer with their


details including optional attributes like date of birth, email, and identification
details

Displaying Customers (`displayCustomer`): Outputs details of a specific


customer including all associated accounts
Updating Customer Information (`updateCustomerAddress`,
`updateCustomerPhone`): Allows modifying customer address and phone number

Adding Accounts (`addAccount`): Enables adding new accounts to a customer


with initial balance and interest rate (if applicable)

Displaying Account Information (`displayAccount`): Shows account details


including account number, type, balance, and interest rate

Transaction Operations (`credit`, `debit`): Allows crediting (depositing) or


debiting (withdrawing) money from an account

Searching Customers (`searchCustomerByName`, `searchCustomerByPhone`,


`searchCustomerByAccountNumber`): Facilitates finding customers based on their
name, phone number, or account number

3 Example Usage:

The `main` function demonstrates usage scenarios by adding customers, adding


accounts, performing transactions, and displaying customer and account details

Detailed Analysis

Pros:

Modular Design: The program is structured into functions for specific tasks (eg,
adding customers, handling accounts), promoting code reusability and
maintainability

Data Encapsulation: Customer and account details are encapsulated within


structures, facilitating organized data management and reducing complexity
Functionality: Provides essential banking operations such as account creation,
transaction handling, and customer information management

Search Functionality: Allows efficient retrieval of customer information based on


various criteria, enhancing user experience

Cons:

Limited Error Handling: The program lacks comprehensive error handling


mechanisms (eg, input validation, handling insufficient balance), which could lead
to unexpected behavior in certain scenarios

Static Data Storage: Uses static arrays for customers and accounts
(`MAX_CUSTOMERS` and `MAX_ACCOUNTS`), which may limit scalability for larger
systems

Simplistic Account Management: Accounts have basic attributes like balance and
interest rate, lacking more complex features like transaction history or account
status tracking

Minimal Security Measures: The program does not address security concerns such
as user authentication or secure data handling, which are crucial in realworld
banking applications

Potential Improvements:

Dynamic Memory Allocation: Replace static arrays with dynamic


memory allocation to handle a variable number of customers and
accounts more efficiently
Error Handling: Implement robust error handling and validation
mechanisms to handle edge cases and ensure data integrity
Enhanced Account Features: Introduce additional account features such as transaction history, overdraft
protection, or different types of fees

Security Enhancements: Incorporate security measures like encryption for sensitive data and user
authentication for accessing accounts

User Interface: Develop a userfriendly interface (eg, commandline menu or graphical interface) to
improve usability and interaction with the banking system

Conclusion

In summary, while the provided program offers basic functionality for


managing customers and accounts in a simulated banking environment,
there are several areas for enhancement to better align with realworld
banking systems By addressing these improvements, the program could
become more robust, secure, and scalable, offering a more
comprehensive solution for banking operations simulation
Adding Attributes:

1. Date of Birth (DOB)

Add a `dob` attribute to the `Customer` structure to store the date of birth.

Example: `char dob[11];` (assuming format "YYYY-MM-DD").

2. Email Address:

Include an `email` attribute in the `Customer` structure to store the customer's email address.

Example: `char email[50];`.

3. Identification Details:

Add attributes like `idType` (type of identification document) and `idNumber` (identification number).

Example: `char idType[20];` and `char idNumber[50];`.

4. Account Status:

Introduce a `status` attribute in the `Account` structure to indicate whether the account is active,
closed, or suspended.

Example: `int status;` (where 0 = active, 1 = closed, etc.).

Removing Attributes:

1. Nominee:

-If nominee details are not needed, remove the `nominee` attribute from the `Customer` structure.

Example: Delete `char nominee[50];`.


2. Multiple Accounts:

If customers are only allowed a single account, remove the array of `Account` structures from the
`Customer` structure (`accounts[MAX_ACCOUNTS]`).

Example: Adjust `Customer` structure to hold a single `Account` instead of an array.

Other Considerations:

1. Enhanced Account Information:

Extend the `Account` structure to include more details like interest rate, overdraft limit, or transaction
history.

Example: Add `float interestRate;` and `float overdraftLimit;`.

2. Security and Authentication:

Implement additional attributes or methods for security purposes, such as PIN numbers for account
access.

3. Transaction Types:

Introduce an enumeration or additional attributes in the `Account` structure to differentiate between


transaction types (e.g., deposit, withdrawal, transfer).

4. Data Validation:

Implement validation mechanisms for attributes like phone numbers, email addresses, and
identification numbers to ensure data integrity.

Additional Attributes: The `Customer` structure now includes `dob` (date of birth), `email`, `idType` (type
of identification), and `idNumber` (identification number).
Modified Functions: Functions like `addCustomer` and `displayCustomer` have been updated to handle
these additional attributes.

Account Enhancements: The `Account` structure now includes `interestRate` to represent the interest
rate for accounts that earn interest.

You might also like