Bank Management System

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

Jaypee Institute of Information Technology, Noida

DEPARTMENT OF COMPUTER SCIENCE &


ENGINEERING AND INFORMATION TECHNOLOGY

Project Title
BANK MANAGEMENT SYSTEM

Team Members
________________
________________
________________
________________

Course Name: Software Development Fundamentals - 1

Course Code: 15B11CI111


Program: B. Tech. CSE
1st Year 1st Sem
2023 - 2024
Abstract of the Project

The bank management system is a C program designed to facilitate the management of bank operations.
The program allows users to create and manage bank accounts, deposit and withdraw amounts from the
balance in a bank account, create, update and delete records. The system employs various data structures
such as arrays, pointers, structures etc. to manage information on banking transactions. Files are used to
store the various records of customer bank accounts.
The program offers functionalities such as balance enquiry (checking bank balance), updating, creating,
deleting, searching records, depositing, withdrawing balance from accounts. The bank management system
is designed to improve the efficiency and accuracy of bank operations, enhance customer experience, and
develop a user friendly interface.

Objective
The aim of the project is to create a bank management system using C programming language. Using this
management system, a user would be able to perform various operations on the data stored in the system.

Features
The various features of the project are described below:

View Records: The user will be able to view all the information regarding an account, like account holder,
address, date of birth, aadhar card number, pan card number, amount of money in the account for all the
registered accounts in the bank at once.

Create Records: In this feature, the user will be able to create a new bank account according to the
information that will be inputted by them such as name of the account holder(s), address, date of birth,
aadhar card number, pan card number and minimum deposit amount.

Read Record: The user will be able to read a particular record based on their bank account information such
as account holder(s) name, bank branch, balance or any other field, valid to their own account.

Update Records: The user will be able to edit the record of their own bank account under a certain field that
is editable such as name of the account holder(s), address, date of birth, phone number and email address.

Delete Records: The user will be able to close down their bank account which will also delete all the details
of the user that were stored in the account. Search Records: The features also allows the user to easily
access or find a particular record. This can be achieved by simply inputting a name or account number.

Balance enquiry: It also has a balance enquiry feature through which, after appropriate authentication, the
user can check the balance in their bank account.

Cash deposit: This feature allows the user to make a deposit in their bank account. The balance in the
account is updated accordingly.
Cash withdrawal: This feature enables users to withdraw funds from their bank accounts. The balance in
the account is updated accordingly.

Design Of The Project


Here is an explanation of the main parts of the program:

1. Header Files:

#include<stdio.h>: Standard input/output functions.

#include<stdlib.h>: Standard library functions.

#include<string.h>: String manipulation functions.

#include<windows.h>: Windows-specific functions for clearing the screen (system("cls"))

2. Global Variables:

int i, j: Global variables used for loop control.

int main_exit: Global variable to control program exit.

3. Structures:

struct date: Structure to store date information (month, day, year).

anonymous structure: A structure without a name, used to define the main structure containing account
details (`add`, `upd`, `check`, `rem`, `transaction`).

4. Functions:

interest: Calculates simple interest based on time, amount, and rate.

fordelay: Delays execution for a specified period.

new_acc: Function to create a new bank account.

view_list: Function to view the list of customer accounts.

edit: Function to update account information.


transact: Function to perform transactions (deposit, withdraw, transfer, bill payment).

erase: Function to remove an existing account.

see: Function to check details of an existing account.

close: Function to exit the program.

menu: Main menu function to display options and call corresponding functions.

5. Main Function:

The main function begins by requesting a password to log in.

After successful login, it displays the main menu and allows the user to choose from various banking
operations.

6. Password Protection:

The program uses a simple password protection mechanism where the user needs to enter a password to
access the banking system.

7. File Handling:

The program uses file handling (`record.dat`) to store customer account information persistently.

File operations include reading, writing, updating, and deleting records.

8. Error Handling:

The program includes basic error handling, such as checking for duplicate account numbers during the
account creation process.

9. Bill Payment Feature:

The program includes a feature for bill payment, where the user can choose different types of bills
(electricity, gas, education, broadband, cable TV) and make payments.

10. Menu Driven:

The main menu is implemented using a switch-case statement, allowing the user to choose various banking
operations interactively

Implementation Of the Project


#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<windows.h>
#include<conio.h>

int i, j;
int main_exit;

// Function prototype
void menu();

// Structure to represent a date


struct date {
int month;
int day;
int year;
};

// Structure to represent a bank account


struct {
char name[60];
int acc_no, age;
char address[60];
char citizenship[15];
double phone;
char acc_type[10];
float amt;
struct date dob; // Date of Birth
struct date deposit; // Date of deposit
struct date withdraw; // Date of withdrawal
} add, upd, check, rem, transaction;

// Function to calculate interest


float interest(float t, float amount, int rate) {
float SI;
SI = (rate * t * amount) / 100.0;
return (SI);
}

// Function to introduce a delay for a given number of iterations


void fordelay(int j) {
int i, k;
for (i = 0; i < j; i++)
k = i;
}

// Function to handle errors related to file operations


int error_handle() {
FILE *fp; // Declare a file pointer
fp = fopen("record.dat", "r"); // Open the file in read mode

if (fp == NULL) {
printf("ERROR IN FILE CREATION\n");
return 0;
}
}

// Function to create a new account


void new_acc() {
int choice;
char nl[1];
FILE *ptr; // Declare a file pointer

// Open the file in append and read mode


ptr = fopen("record.dat", "a+");

account_no:
system("cls");
printf("\t\t\tADD RECORD");
printf("\n\n\nEnter today's date(dd/mm/yyyy):");
scanf("%d/%d/%d", &add.deposit.day, &add.deposit.month, &add.deposit.year);
printf("\nEnter the account number:");
scanf("%d", &check.acc_no);

// Check if the account number already exists


while (fscanf(ptr, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", &add.acc_no, add.name,
&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF) {
if (check.acc_no == add.acc_no) {
printf("Account no. already in use!");
fordelay(1000000000);
goto account_no;
}
}

// Assign the entered account number


add.acc_no = check.acc_no;

printf("\nEnter the name:");


scanf("%s", add.name);
printf("\nEnter the date of birth(dd/mm/yyyy):");
scanf("%d/%d/%d", &add.dob.day, &add.dob.month, &add.dob.year);
printf("\nEnter the age:");
scanf("%d", &add.age);
printf("\nEnter the address:");
scanf("%s", add.address);
printf("\nEnter the citizenship number:");
scanf("%s", add.citizenship);
printf("\nEnter the phone number: ");
scanf("%lf", &add.phone);
printf("\nEnter the amount to deposit: Rs.");
scanf("%f", &add.amt);
printf("\nType of account:\n\t#Saving\n\t#Current\n\t#Fixed1(for 1 year)\n\t#Fixed2(for 2
years)\n\t#Fixed3(for 3 years)\n\n\tEnter your choice (lowercase):");
scanf("%s", add.acc_type);

// Write the account details to the file


fprintf(ptr, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no, add.name,
add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);

// Close the file pointer to release resources


fclose(ptr);

printf("\nAccount created successfully!");

add_invalid:
printf("\n\n\n\t\tEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");

if (main_exit == 1)
menu();
else if (main_exit == 0)
close();
else
{
printf("\nInvalid!\a");
goto add_invalid;
}
}

// Function to view the list of accounts


void view_list()
{
FILE *view;
view = fopen("record.dat", "r"); // Open the file in read mode
int test = 0; // Variable to check if there are records

system("cls");
printf("\nACC. NO.\tNAME\t\t\tADDRESS\t\t\tPHONE\n");

// Read account details from the file and display them


while (fscanf(view, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,
&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
printf("\n%6d\t %10s\t\t\t%10s\t\t%.0lf", add.acc_no, add.name, add.address, add.phone);
test++;
}

fclose(view); // Close the file pointer

// Display a message if there are no records


if (test == 0)
{
system("cls");
printf("\nNO RECORDS!\n");
}

view_list_invalid:
printf("\n\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");
if (main_exit == 1)
menu();
else if (main_exit == 0)
close();
else
{
printf("\nInvalid!\a");
goto view_list_invalid;
}
}

void edit(void)
{
int choice, test = 0, ret, ret1;
FILE *old, *newrec;

// Open the existing file in read mode


old = fopen("record.dat", "r");

// Open a new file in write mode


newrec = fopen("new.dat", "w");

// Prompt user for the account number to change information


printf("\nEnter the account no. of the customer whose information you want to change:");
scanf("%d", &upd.acc_no);

// Loop through the existing file to read records


while (fscanf(old, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,
&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
if (add.acc_no == upd.acc_no)
{
test = 1;

// Prompt user for the type of information to change


printf("\nWhich information do you want to change?\n1.Address\n2.Phone\n\nEnter your choice(1
for address and 2 for phone):");
scanf("%d", &choice);
system("cls");

if (choice == 1)
{
// Update address and write to the new file
printf("Enter the new address:");
scanf("%s", upd.address);
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no, add.name,
add.dob.day, add.dob.month, add.dob.year, add.age, upd.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
system("cls");
printf("Changes saved!");
}
else if (choice == 2)
{
// Update phone number and write to the new file
printf("Enter the new phone number:");
scanf("%lf", &upd.phone);
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no, add.name,
add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, upd.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
system("cls");
printf("Changes saved");
}
}
else
{
// Copy the existing record to the new file as it is
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no, add.name,
add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
}
}

// Close the existing file


fclose(old);
// Close the new file
fclose(newrec);

// Remove the existing file


ret = remove("record.dat");

// Rename the new file to the existing file name


ret1 = rename("new.dat", "record.dat");

if (test != 1)
{
// Display a message if the record is not found
printf("\nRecord not found!\n");
edit_invalid:
printf("\nEnter 0 to try again, 1 to return to main menu and 2 to exit:");
scanf("%d", &main_exit);
system("cls");

// Redirect based on user input


if (main_exit == 1)
menu();
else if (main_exit == 2)
close();
else if (main_exit == 0)
edit();
else
{
printf("\nInvalid!\a");
goto edit_invalid;
}
}
else
{
// Prompt user for the next action
printf("\n\n\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");

// Redirect based on user input


if (main_exit == 1)
menu();
else
close();
}
}

void transact(void)
{
int choice, test = 0, transferacct;
FILE *old, *newrec;

old = fopen("record.dat", "r");


newrec = fopen("new.dat", "w");

printf("Enter the account no. of the customer:");


scanf("%d", &transaction.acc_no);

while (fscanf(old, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,


&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
if (add.acc_no == transaction.acc_no)
{
test = 1;
if (strcmp(add.acc_type, "fixed1") == 0 || strcmp(add.acc_type, "fixed2") == 0 ||
strcmp(add.acc_type, "fixed3") == 0)
{
// If the account type is fixed, restrict deposit and withdraw
printf("\a\a\a\n\nYOU CANNOT DEPOSIT OR WITHDRAW CASH IN FIXED ACCOUNTS");
fordelay(1000000000);
system("cls");
menu();
}
else
{
printf("\n\nDo you want to\n1. Deposit\n2. Withdraw\n3. Transfer\n4. Bill Payment\n\nEnter your
choice(1 for deposit, 2 for withdraw, 3 for transfer, 4 for bill payment):");
scanf("%d", &choice);

if (choice == 1)
{
// Deposit money into the account
printf("Enter the amount you want to deposit: Rs. ");
scanf("%f", &transaction.amt);
add.amt += transaction.amt;
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no,
add.name, add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
printf("\n\nDeposited successfully!");
}
else if (choice == 2)
{
// Withdraw money from the account
printf("Enter the amount you want to withdraw: Rs. ");
scanf("%f", &transaction.amt);
if (transaction.amt > add.amt)
{
printf("\nInsufficient balance!");
fclose(old);
fclose(newrec);
remove("new.dat");
fordelay(1000000000);
system("cls");
menu();
}
else
{
add.amt -= transaction.amt;
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no,
add.name, add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
printf("\n\nWithdrawn successfully!");
}
}
else if (choice == 3)
{
// Transfer money to another account
printf("Enter the amount you want to transfer:");
scanf("%f", &transaction.amt);
printf("Enter the account no. to transfer money to:");
scanf("%d", &transferacct);
if (transaction.amt > add.amt)
{
printf("\nInsufficient balance!");
fclose(old);
fclose(newrec);
remove("new.dat");
fordelay(1000000000);
system("cls");
menu();
}
else
{
add.amt -= transaction.amt;
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no,
add.name, add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);

while (fscanf(old, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no,


add.name, &add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship,
&add.phone, add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) !=
EOF)
{
if (add.acc_no == transferacct)
{
add.amt += transaction.amt;
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no,
add.name, add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
}
else
{
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no,
add.name, add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
}
}

printf("\n\nTransferred successfully!");
}
}
}
}
else if (choice == 4)
{
// Define a structure to store payment details
struct PaymentDetails
{
char agencyName[150];
union
{
int consumerNumber;
int businessPartnerNumber;
struct
{
char state[20];
char city[20];
char instituteName[150];
} education;
struct
{
int accountId;
} broadband;
} details;
float amount;
};

// Function to validate the length of consumer number, business partner number, and
account ID
int ValidateLength(int number)
{
// Assuming a 10-digit limit for integers
return (number >= 1000000000) && (number <= 9999999999);
}

// Function to make bill payments


void BillPayments()
{

int continuePayments = 1;

while (add.amt > 0.0 && continuePayments)


{
struct PaymentDetails payment;

printf("Choose which bill to pay:\n");


printf("1. Electricity\n2. Gas\n3. Education Fees\n4. Broadband/Landline\n5. Cable
TV\n");

int choice;
scanf("%d", &choice);

// Clear the input buffer


while ((getchar()) != '\n');

switch (choice)
{

case 1:
{
// Display the list of electricity agencies
printf("Choose the electricity agency:\n");
printf("1. Uttar Pradesh Power Corporation Ltd\n");
printf("2. Paschimanchal Vidyut Vitran Nigam Ltd\n");
printf("3. Maharashtra State Electricity Distribution Co. Ltd\n");
printf("4. Tamil Nadu Generation and Distribution Corporation Ltd\n");
printf("5. West Bengal State Electricity Distribution Company Ltd\n");
printf("6. Gujarat Urja Vikas Nigam Ltd\n");
printf("7. Karnataka Power Transmission Corporation Ltd\n");
printf("8. Kerala State Electricity Board Ltd\n");
printf("9. Rajasthan Rajya Vidyut Utpadan Nigam Ltd\n");
printf("10. Madhya Pradesh Paschim Kshetra Vidyut Vitaran Company
Ltd\n");
printf("11. Nuclear Power Corporation of India\n");
printf("12. PowerGrid Corporation of India\n");
printf("13. NHPC Limited\n");
printf("14. NTPC Limited\n");
printf("15. Power System Operation Corporation\n");
printf("16. Neyveli Lignite Corporation\n");
printf("17. Damodar Valley Corporation\n");
printf("18. Bureau of Energy Efficiency\n");
printf("19. Other\n");

// Get the user's choice


int agencyChoice;
scanf("%d", &agencyChoice);

// Check if the choice is valid


if (agencyChoice >= 1 && agencyChoice <= 18)
{
// Agency names and account numbers
char *agencyNames[] = {"Uttar Pradesh Power Corporation Ltd",
"Paschimanchal Vidyut Vitran Nigam Ltd",
"Maharashtra State Electricity Distribution Co. Ltd",
"Tamil Nadu Generation and Distribution Corporation Ltd",
"West Bengal State Electricity Distribution Company Ltd",
"Gujarat Urja Vikas Nigam Ltd",
"Karnataka Power Transmission Corporation Ltd",
"Kerala State Electricity Board Ltd",
"Rajasthan Rajya Vidyut Utpadan Nigam Ltd",
"Madhya Pradesh Paschim Kshetra Vidyut Vitaran
Company Ltd",
"Nuclear Power Corporation of India",
"PowerGrid Corporation of India",
"NHPC Limited", "NTPC Limited",
"Power System Operation Corporation",
"Neyveli Lignite Corporation",
"Damodar Valley Corporation",
"Bureau of Energy Efficiency"};

int agencyAccountNumbers[] = {1234567890,


9876543210,
1111222233,
4444555566,
7777888899,
1011121314,
1516171819,
2021222324,
2526272829,
3031323334,
5555666677,
8888999900,
1212121212,
3434343434,
5656565656,
7878787878,
9898989898,
2323232323};

// Assign the selected agency name


strcpy(payment.agencyName, agencyNames[agencyChoice - 1]);

// Display the account number


printf("Account number for %s: %d\n", payment.agencyName,
agencyAccountNumbers[agencyChoice - 1]);
}
else if (agencyChoice == 19)
{
// If the choice is 'Other', ask for the agency name and account number
printf("Enter the name of the electricity agency: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.agencyName);

// Ask for the account number


printf("Enter the account number for %s: ", payment.agencyName);
scanf("%d", &payment.details.consumerNumber);
}
else
{
// If the choice is not valid, ask for the agency name and account number
printf("Invalid choice. Enter the name of the electricity agency: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.agencyName);

// Ask for the account number


printf("Enter the account number for %s: ", payment.agencyName);
scanf("%d", &payment.details.consumerNumber);
}

// Validate and get the consumer number


for (;;)
{
printf("Enter the consumer number (10 digits): ");
scanf("%d", &payment.details.consumerNumber);
if (ValidateLength(payment.details.consumerNumber))
{
break;
}
printf("Try again. ");
}
break;
}

case 2:
// Display the list of gas agencies
printf("Choose the gas agency:\n");
printf("1. Indraprastha Gas Limited\n");
printf("2. Mahanagar Gas Limited\n");
printf("3. Adani Gas Limited\n");
printf("4. Gujarat Gas Limited\n");
printf("5. GAIL Gas Limited\n");
printf("6. Tripura Natural Gas Company Ltd\n");
printf("7. Assam Gas Company Ltd\n");
printf("8. Green Gas Limited\n");
printf("9. Central U.P. Gas Limited\n");
printf("10. Sabarmati Gas Limited\n");
printf("11. Other\n");

// Get the user's choice


int gasAgencyChoice;
scanf("%d", &gasAgencyChoice);

// Check if the choice is valid


if (gasAgencyChoice >= 1 && gasAgencyChoice <= 10)
{
// Gas agency names and business partner numbers
char *gasAgencyNames[] = {"Indraprastha Gas Limited",
"Mahanagar Gas Limited",
"Adani Gas Limited",
"Gujarat Gas Limited",
"GAIL Gas Limited",
"Tripura Natural Gas Company Ltd",
"Assam Gas Company Ltd",
"Green Gas Limited",
"Central U.P. Gas Limited",
"Sabarmati Gas Limited"};

int gasAgencyBusinessPartnerNumbers[] = {1234567890,


9876543210,
1111222233,
4444555566,
7777888899,
1011121314,
1516171819,
2021222324,
2526272829,
3031323334};

// Assign the selected gas agency name


strcpy(payment.agencyName, gasAgencyNames[gasAgencyChoice - 1]);

// Display the business partner number


printf("Business partner number for %s: %d\n", payment.agencyName,
gasAgencyBusinessPartnerNumbers[gasAgencyChoice - 1]);
}
else
{
// If the choice is not valid, ask for the gas agency name and business
partner number
printf("Enter the name of the gas agency: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.agencyName);

// Ask for the business partner number


printf("Enter the business partner number for %s: ", payment.agencyName);
scanf("%d", &payment.details.businessPartnerNumber);
}

// Validate and get the business partner number


for (;;)
{
printf("Enter the business partner number (10 digits): ");
scanf("%d", &payment.details.businessPartnerNumber);
if (ValidateLength(payment.details.businessPartnerNumber))
{
break;
}
printf("Try again. ");
}
break;

case 3:
{
// Display the list of states
printf("Choose the state:\n");
printf("1. Andhra Pradesh\n2. Arunachal Pradesh\n3. Assam\n4. Bihar\n5.
Chhattisgarh\n");
printf("6. Goa\n7. Gujarat\n8. Haryana\n9. Himachal Pradesh\n10.
Jharkhand\n");
printf("11. Karnataka\n12. Kerala\n13. Madhya Pradesh\n14.
Maharashtra\n15. Manipur\n");
printf("16. Meghalaya\n17. Mizoram\n18. Nagaland\n19. Odisha\n20.
Punjab\n");
printf("21. Rajasthan\n22. Sikkim\n23. Tamil Nadu\n24. Telangana\n25.
Tripura\n");
printf("26. Uttar Pradesh\n27. Uttarakhand\n28. West Bengal\n29. Jammu
and Kashmir\n30. Ladakh\n");
printf("31. Andaman and Nicobar Islands\n32. Chandigarh\n33. Dadra
and Nagar Haveli and Daman and Diu\n");
printf("34. Lakshadweep\n35. Delhi\n36. Puducherry\n");
// Get the total number of states
int totalStates = 36; // Update this based on the total number of states
int stateChoice;

// Get the user's choice


scanf("%d", &stateChoice);

// Check if the choice is valid


if (stateChoice >= 1 && stateChoice <= totalStates)
{
// State names
char *stateNames[] =
{
"Andhra Pradesh",
"Arunachal Pradesh",
"Assam",
"Bihar",
"Chhattisgarh",
"Goa",
"Gujarat",
"Haryana",
"Himachal Pradesh",
"Jharkhand",
"Karnataka",
"Kerala",
"Madhya Pradesh",
"Maharashtra",
"Manipur",
"Meghalaya",
"Mizoram",
"Nagaland",
"Odisha",
"Punjab",
"Rajasthan",
"Sikkim",
"Tamil Nadu",
"Telangana",
"Tripura",
"Uttar Pradesh",
"Uttarakhand",
"West Bengal",
"Jammu and Kashmir",
"Ladakh",
"Andaman and Nicobar Islands",
"Chandigarh",
"Dadra and Nagar Haveli and Daman and Diu",
"Lakshadweep",
"Delhi",
"Puducherry"};

// Capital cities
char *capitalCities[] =
{
"Amaravati",
"Itanagar",
"Dispur",
"Patna",
"Raipur",
"Panaji",
"Gandhinagar",
"Chandigarh",
"Shimla",
"Ranchi",
"Bengaluru",
"Thiruvananthapuram",
"Bhopal",
"Mumbai",
"Imphal",
"Shillong",
"Aizawl",
"Kohima",
"Bhubaneswar",
"Chandigarh",
"Jaipur",
"Gangtok",
"Chennai",
"Hyderabad",
"Agartala",
"Lucknow",
"Dehradun",
"Kolkata",
"Srinagar",
"Leh",
"Port Blair",
"Chandigarh",
"Daman",
"Kavaratti",
"New Delhi",
"Puducherry"};

// Assign the selected state name


strcpy(payment.details.education.state, stateNames[stateChoice - 1]);

// Display the state name


printf("Selected state: %s\n", payment.details.education.state);
// Ask the user to confirm the capital city
char confirm;
printf("Is %s the city where the institute is located? (y/n): ",
capitalCities[stateChoice - 1]);
scanf(" %c", &confirm);

if (confirm == 'n' || confirm == 'N')


{
// If the capital city is not the one where the institute is located, ask
for the city name
printf("Enter the name of the city: ");

// Consume the newline character left in the buffer


getchar();
gets(payment.details.education.city);
}
else
{
// Assign the capital city
strcpy(payment.details.education.city, capitalCities[stateChoice - 1]);
}

// Display the selected city


printf("Selected city: %s\n", payment.details.education.city);

// Ask for the name of the institute


printf("Enter the name of the institute: ");

// Consume the newline character left in the buffer


getchar();
gets(payment.details.education.instituteName);
}
else
{
// If the choice is not valid, ask for the state name
printf("Invalid choice. Enter the name of the state: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.details.education.state);

// Ask for the city name


printf("Enter the name of the city: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.details.education.city);

// Ask for the name of the institute


printf("Enter the name of the institute: ");
getchar(); // Consume the newline character left in the buffer
gets(payment.details.education.instituteName);
}

break;
}
case 4:
// Display the list of broadband agencies from India
printf("Choose the broadband agency:\n");
printf("1. BSNL Broadband\n2. Airtel Broadband\n3. Jio Fiber\n4. ACT
Fibernet\n5. Hathway Broadband\n");
printf("6. Tikona Broadband\n7. Excitel Broadband\n8. You Broadband\n9.
Siti Broadband\n10. RailWire Broadband\n11. Other\n");

int broadbandChoice;
scanf("%d", &broadbandChoice);

// Check if the choice is valid


if (broadbandChoice >= 1 && broadbandChoice <= 10)
{
// Broadband agency names
char *broadbandAgencies[] = {"BSNL Broadband",
"Airtel Broadband",
"Jio Fiber",
"ACT Fibernet",
"Hathway Broadband",
"Tikona Broadband",
"Excitel Broadband",
"You Broadband",
"Siti Broadband",
"RailWire Broadband"};

// Assign the selected broadband agency name


strcpy(payment.agencyName, broadbandAgencies[broadbandChoice -
1]);

// Display the selected broadband agency name


printf("Selected broadband agency: %s\n", payment.agencyName);
}
else
{
// If the choice is not valid, ask for the broadband agency name
printf("Enter the name of the broadband agency: ");

// Consume the newline character left in the buffer


getchar();
gets(payment.agencyName);
}
// Ask for the broadband account ID
for (;;)
{
printf("Enter the broadband account ID (10 digits): ");
scanf("%d", &payment.details.broadband.accountId);
if (ValidateLength(payment.details.broadband.accountId))
{
break;
}
printf("Try again. ");
}
break;

case 5:
// Display the list of cable TV agencies
printf("Choose the cable TV agency:\n");
printf("1. Tata Sky\n2. Dish TV\n3. Airtel Digital TV\n4. Sun Direct\n5.
D2H\n");
printf("6. Hathway Cable\n7. Den Networks\n8. Siti Cable\n9. Asianet
Digital\n10. GTPL\n11. Other\n");

int cableTVChoice;
scanf("%d", &cableTVChoice);

// Check if the choice is valid


if (cableTVChoice >= 1 && cableTVChoice <= 10)
{
// Cable TV agency names
char *cableTVAagencies[] =
{"Tata Sky",
"Dish TV",
"Airtel Digital TV",
"Sun Direct",
"D2H",
"Hathway Cable",
"Den Networks",
"Siti Cable",
"Asianet Digital",
"GTPL"};

// Assign the selected cable TV agency name


strcpy(payment.agencyName, cableTVAagencies[cableTVChoice -
1]);

// Display the selected cable TV agency name


printf("Selected cable TV agency: %s\n", payment.agencyName);
}
else
{
// If the choice is not valid, ask for the cable TV agency name
printf("Enter the name of the cable TV agency: ");

// Consume the newline character left in the buffer


getchar();
gets(payment.agencyName);
}

// Ask for the cable TV consumer number


for (;;)
{
printf("Enter the consumer number (10 digits): ");
scanf("%d", &payment.details.consumerNumber);
if (ValidateLength(payment.details.consumerNumber))
{
break;
}
printf("Try again. ");
}
break;

default:
printf("Invalid choice\n");
return;
}

printf("Enter the amount to be paid: Rs.");


scanf("%f", &payment.amount);

printf("Payment is being made\n");

if (add.amt >= payment.amount)


{
printf("Payment is successful\n");
add.amt = add.amt - payment.amount;
printf("Remaining balance: Rs. %.2f\n", add.amt);
}
else
{
printf("Insufficient balance. Payment failed\n");
break;
// Exit the loop if the balance is insufficient
}

printf("Do you want to pay another bill? (1 for Yes / 0 for No): ");
scanf("%d", &continuePayments);
if (!continuePayments)
{
printf("Ok\n");
}
else if (add.amt == 0)
{
printf("Insufficient balance.");
}
}
}
BillPayments();
fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f
%d/%d/%d\n",add.acc_no,add.name,add.dob.day,add.dob.month,add.dob.year,add.age,add.address,add.
citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
printf("\n\Bill paid successfully!");
}
else
{
fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f
%d/%d/%d\n",add.acc_no,add.name,add.dob.day,add.dob.month,add.dob.year,add.age,add.address,add.
citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
}
}
fclose(old); // Close the existing file
fclose(newrec); // Close the new file
int ret = remove("record.dat"); // Remove the existing file
int ret1 = rename("new.dat", "record.dat"); // Rename the new file to the existing file name

if(test != 1)
{
// If the record is not found
printf("\n\nRecord not found!");

transact_invalid:
printf("\n\n\nEnter 0 to try again, 1 to return to the main menu, and 2 to exit:");
scanf("%d", &main_exit);
system("cls");

if (main_exit == 0)
transact();
else if (main_exit == 1)
menu();
else if (main_exit == 2)
close();
else
{
printf("\nInvalid!");
goto transact_invalid;
}
}
else
{
// If the record is found
printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");

if (main_exit == 1)
menu();
else
close();
}
}

void erase(void)
{
FILE *old, *newrec;
int test = 0;
old = fopen("record.dat", "r"); // Open the existing file in read mode
newrec = fopen("new.dat", "w"); // Open a new file in write mode

printf("Enter the account no. of the customer you want to delete:");


scanf("%d", &rem.acc_no);

while (fscanf(old, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,


&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
if (add.acc_no != rem.acc_no)
fprintf(newrec, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n", add.acc_no, add.name,
add.dob.day, add.dob.month, add.dob.year, add.age, add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.month, add.deposit.day, add.deposit.year);
else
{
test++;
printf("\nRecord deleted successfully!\n");
}
}

fclose(old); // Close the existing file


fclose(newrec); // Close the new file
remove("record.dat"); // Remove the existing file
rename("new.dat", "record.dat"); // Rename the new file to the existing file name

if (test == 0)
{
printf("\nRecord not found!!\a\a\a");

erase_invalid:
printf("\nEnter 0 to try again, 1 to return to main menu, and 2 to exit:");
scanf("%d", &main_exit);

if (main_exit == 1)
menu();
else if (main_exit == 2)
close();
else if (main_exit == 0)
erase();
else
{
printf("\nInvalid!\a");
goto erase_invalid;
}
}
else
{
printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");

if (main_exit == 1)
menu();
else
close();
}
}

void see(void)
{
FILE *ptr;
int test = 0, rate;
int choice;
float time;
float intrst;
ptr = fopen("record.dat", "r");

// Prompt user to choose the search criteria


printf("Do you want to check by\n1.Account no\n2.Name\nEnter your choice:");
scanf("%d", &choice);

if (choice == 1)
{
// User wants to search by account number
printf("Enter the account number:");
scanf("%d", &check.acc_no);

// Loop through the file to find the account with the given account number
while (fscanf(ptr, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,
&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
if (add.acc_no == check.acc_no)
{
system("cls");
test = 1;

// Display account details


printf("\nAccount NO.:%d\nName:%s \nDOB:%d/%d/%d \nAge:%d \nAddress:%s \nCitizenship
No:%s \nPhone number:%.0lf \nType Of Account:%s \nAmount deposited:Rs. %.2f \nDate Of
Deposit:%d/%d/%d\n\n", add.acc_no, add.name, add.dob.month, add.dob.day, add.dob.year, add.age,
add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.day, add.deposit.month, add.deposit.year);

// Calculate and display interest based on account type


if (strcmp(add.acc_type, "fixed1") == 0)
{
time = 1.0;
rate = 9;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.day,
add.deposit.month, add.deposit.year + 1);
}
else if (strcmp(add.acc_type, "fixed2") == 0)
{
time = 2.0;
rate = 11;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.day,
add.deposit.month, add.deposit.year + 2);
}
else if (strcmp(add.acc_type, "fixed3") == 0)
{
time = 3.0;
rate = 13;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.day,
add.deposit.month, add.deposit.year + 3);
}
else if (strcmp(add.acc_type, "saving") == 0)
{
time = (1.0 / 12.0);
rate = 8;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d of every month", intrst, add.deposit.day);
}
else if (strcmp(add.acc_type, "current") == 0)
{
printf("\n\nYou will get no interest\a\a");
}
}
}
}
else if (choice == 2)
{
// User wants to search by name
printf("Enter the name:");
scanf("%s", check.name);

// Loop through the file to find the account with the given name
while (fscanf(ptr, "%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d", &add.acc_no, add.name,
&add.dob.day, &add.dob.month, &add.dob.year, &add.age, add.address, add.citizenship, &add.phone,
add.acc_type, &add.amt, &add.deposit.month, &add.deposit.day, &add.deposit.year) != EOF)
{
if (strcmpi(add.name, check.name) == 0)
{
system("cls");
test = 1;

// Display account details


printf("\nAccount No.:%d\nName:%s \nDOB:%d/%d/%d \nAge:%d \nAddress:%s \nCitizenship
No:%s \nPhone number:%.0lf \nType Of Account:%s \nAmount deposited:Rs.%.2f \nDate Of
Deposit:%d/%d/%d\n\n", add.acc_no, add.name, add.dob.month, add.dob.day, add.dob.year, add.age,
add.address, add.citizenship, add.phone,
add.acc_type, add.amt, add.deposit.day, add.deposit.month, add.deposit.year);

// Calculate and display interest based on account type


if (strcmp(add.acc_type, "fixed1") == 0)
{
time = 1.0;
rate = 9;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.day,
add.deposit.month, add.deposit.year + 1);
}
else if (strcmp(add.acc_type, "fixed2") == 0)
{
time = 2.0;
rate = 11;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.day,
add.deposit.month, add.deposit.year + 2);
}
else if (strcmp(add.acc_type, "fixed3") == 0)
{
time = 3.0;
rate = 13;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d/%d/%d", intrst, add.deposit.month,
add.deposit.day, add.deposit.year + 3);
}
else if (strcmp(add.acc_type, "saving") == 0)
{
time = (1.0 / 12.0);
rate = 8;
intrst = interest(time, add.amt, rate);
printf("\n\nYou will get Rs.%.2f as interest on %d of every month", intrst, add.deposit.day);
}
else if (strcmpi(add.acc_type, "current") == 0)
{
printf("\n\nYou will get no interest\a\a");
}
}
}
}

// Close the file


fclose(ptr);

if (test != 1)
{
// Display a message if the record is not found
printf("\nRecord not found!!\a\a\a");
see_invalid:
printf("\nEnter 0 to try again, 1 to return to the main menu and 2 to exit:");
scanf("%d", &main_exit);
system("cls");

// Redirect based on user input


if (main_exit == 1)
menu();
else if (main_exit == 2)
close();
else if (main_exit == 0)
see();
else
{
system("cls");
printf("\nInvalid!\a");
goto see_invalid;
}
}
else
{
// Prompt user for the next action
printf("\nEnter 1 to go to the main menu and 0 to exit:");
scanf("%d", &main_exit);
system("cls");

// Redirect based on user input


if (main_exit == 1)
menu();
else
close();
}
}

void close(void)
{
printf("\n\n\n\nThank You!\n");
}

void menu(void)
{
int ch;

// Clear the console screen


system("cls");

// Display the main menu options


printf("\n\n\t\t\tCUSTOMER ACCOUNT BANKING MANAGEMENT SYSTEM");
printf("\n\n\n\t\t\tWELCOME TO THE MAIN MENU");
printf("\n\n\t\t1.Create new account\n\t\t2.Update information of existing account\n\t\t3.For
transactions\n\t\t4.Check the details of existing account\n\t\t5.Removing existing account\n\t\t6.View
customer's list\n\t\t7.Exit\n\n\n\n\n\t\t Enter your choice:");

// Get user input for the chosen option


scanf("%d", &ch);

// Clear the console screen


system("cls");

// Switch statement to redirect based on user choice


switch (ch)
{
case 1:
error_handle();
new_acc();
break;
case 2:
error_handle();
edit();
break;
case 3:
error_handle();
transact();
break;
case 4:
error_handle();
see();
break;
case 5:
error_handle();
erase();
break;
case 6:
error_handle();
view_list();
break;
case 7:
error_handle();
close();
break;
}
}

int main()
{
char pass[10], password[10] = "SIYA";
int i = 0, p = 0;

// Display welcome message and prompt for password


printf("\t\tWELCOME TO THE BANK MANAGEMENT SYSTEM\n");
printf("\t\tEnter the password to login:");

// Loop to capture password input


while (1)
{
pass[p] = getch();
if (pass[p] == 8)
{
p--;
printf("\b \b");
}
else
{
if (pass[p] != '\r')
{
printf("*");
}
else
{
break;
}
p++;
}
}
pass[p] = '\0';

// Check if the entered password matches the preset password


if (strcmp(pass, password) == 0)
{
printf("\nPassword Match!\nLOADING");

// Display loading dots


for (i = 0; i <= 6; i++)
{
fordelay(100000000);
printf(".");
}
system("cls");
menu(); // Call the main menu function if the password is correct
}
else
{
printf("\nWrong password!");

login_try:
// Prompt to try again or exit
printf("\nEnter 1 to try again and 0 to exit:");
scanf("%d", &main_exit);

if (main_exit == 1)
{
system("cls");
main(); // Retry login if user chooses 1
}
else if (main_exit == 0)
{
system("cls");
close(); // Exit the program if user chooses 0
}
else
{
printf("\nInvalid!");
fordelay(1000000000);
system("cls");
goto login_try; // Retry if user enters an invalid option
}
}
return 0;
}

Output Screens
SDF-1 Topics Used
1. File handling in ‘C’
2. Functions
3. Arrays
4. Pointers
5. Structures
6. User defined input

Software Used

1. C as a front-end development environment.

You might also like