0% found this document useful (0 votes)
9 views7 pages

Programming Fundamental Documentation

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)
9 views7 pages

Programming Fundamental Documentation

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/ 7

Programming Fundamental

HITEC UNIVERSITY TAXILA, CANTT


BSCS- 1st Semester
Fall 2024

Semester Project

(Banking Management System)

Submitted To:
Miss. Sibgha Batool

Submitted By:
Muhammad Fahad (24-CS-040)
Muhammad Junaid (24-CS-080)
Farhad Omar (24-CS-)
Roha Abbasi (24-CS-040)
Code:

#include <iostream>
#include <conio.h>
#include <windows.h>
using namespace std;

// Global variables
int total = 0;
string id;

struct Person {
string name, ID, address;
int contact, cash;
} person[100];

// Function prototypes
int choice(); // Main menu, returns exit status
int perData(); // Create new customer account
int show(); // Display all customers
int update(); // Update customer information
int search(); // Search customer by ID
int transactions(); // Perform transactions
int del(); // Delete customer record

int main() {
return choice(); // Call choice and use its return value as the exit code
}

// Function implementations

int choice() {
char ch;
while (true) {
cout << "\n\nPRESS..!!" << endl;
cout << "1. Create new account" << endl;
cout << "2. View customers list" << endl;
cout << "3. Update information of existing account" << endl;
cout << "4. Check the details of an existing account" << endl;
cout << "5. For transactions" << endl;
cout << "6. Remove existing account" << endl;
cout << "7. Exit" << endl;
ch = getch();

system("CLS");

switch (ch) {
case '1':
perData();
break;
case '2':
if (total == 0)
cout << "No data is entered" << endl;
else
show();
break;
case '3':
if (total == 0)
cout << "No data is entered" << endl;
else
update();
break;
case '4':
if (total == 0)
cout << "No data is entered" << endl;
else
search();
break;
case '5':
if (total == 0)
cout << "No data is entered" << endl;
else
transactions();
break;
case '6':
if (total == 0)
cout << "No data is entered" << endl;
else
del();
break;
case '7':
return 0; // Exit the program
default:
cout << "Invalid input" << endl;
break;
}
}
}

int perData() {
cout << "Enter data of Customer " << total + 1 << endl;
cout << "Enter name: ";
cin >> person[total].name;
cout << "ID: ";
cin >> person[total].ID;
cout << "Address: ";
cin >> person[total].address;
cout << "Contact: ";
cin >> person[total].contact;
cout << "Total Cash: ";
cin >> person[total].cash;

total++;
return total; // Return the updated total number of customers
}

int show() {
for (int i = 0; i < total; i++) {
cout << "Data of Customer " << i + 1 << endl;
cout << "Name: " << person[i].name << endl;
cout << "ID: " << person[i].ID << endl;
cout << "Address: " << person[i].address << endl;
cout << "Contact: " << person[i].contact << endl;
cout << "Cash: " << person[i].cash << endl;
}
return total; // Return the number of customers displayed
}

int update() {
cout << "Enter ID of the Customer whose data you want to update: ";
cin >> id;

for (int i = 0; i < total; i++) {


if (id == person[i].ID) {
cout << "Previous data" << endl;
cout << "Name: " << person[i].name << endl;
cout << "ID: " << person[i].ID << endl;
cout << "Address: " << person[i].address << endl;
cout << "Contact: " << person[i].contact << endl;
cout << "Cash: " << person[i].cash << endl;

cout << "\nEnter new data" << endl;


cout << "Enter name: ";
cin >> person[i].name;
cout << "ID: ";
cin >> person[i].ID;
cout << "Address: ";
cin >> person[i].address;
cout << "Contact: ";
cin >> person[i].contact;
cout << "Total Cash: ";
cin >> person[i].cash;
return 1; // Return 1 to indicate success
}
}
cout << "No such record found" << endl;
return 0; // Return 0 to indicate failure
}

int search() {
cout << "Enter ID of the Customer you want to search: ";
cin >> id;

for (int i = 0; i < total; i++) {


if (id == person[i].ID) {
cout << "Name: " << person[i].name << endl;
cout << "ID: " << person[i].ID << endl;
cout << "Address: " << person[i].address << endl;
cout << "Contact: " << person[i].contact << endl;
cout << "Cash: " << person[i].cash << endl;

return 1; // Return 1 if the record is found


}
}
cout << "No such record found" << endl;
return 0; // Return 0 if the record is not found
}

int transactions() {
int cash;
char ch;

cout << "Enter ID of the Customer you want to perform a transaction for: ";
cin >> id;

for (int i = 0; i < total; i++) {


if (id == person[i].ID) {
cout << "Name: " << person[i].name << endl;
cout << "Address: " << person[i].address << endl;
cout << "Contact: " << person[i].contact << endl;
cout << "\nExisting Cash: " << person[i].cash << endl;

cout << "Press 1 to deposit" << endl;


cout << "Press 2 to withdraw" << endl;
ch = getch();

if (ch == '1') {
cout << "How much cash do you want to deposit? ";
cin >> cash;
person[i].cash += cash;
cout << "Your new balance is: " << person[i].cash << endl;
} else if (ch == '2') {
cout << "How much cash do you want to withdraw? ";
cin >> cash;
if (cash > person[i].cash) {
cout << "Insufficient balance!" << endl;
} else {
person[i].cash -= cash;
cout << "Your new balance is: " << person[i].cash << endl;
}
} else {
cout << "Invalid input" << endl;
}

return 1; // Return 1 for a successful transaction


}
}

cout << "No such record found" << endl;


return 0; // Return 0 if the record is not found
}

int del() {
char ch;

cout << "Press 1 to remove a specific record" << endl;


cout << "Press 2 to remove all records" << endl;
ch = getch();

if (ch == '1') {
cout << "Enter ID of the Customer you want to remove: ";
cin >> id;

for (int i = 0; i < total; i++) {


if (id == person[i].ID) {
for (int j = i; j < total - 1; j++) {
person[j] = person[j + 1];
}
total--;
cout << "The record has been deleted" << endl;
return 1; // Return 1 for successful deletion
}
}
cout << "No such record found" << endl;
return 0; // Return 0 if the record is not found
} else if (ch == '2') {
total = 0;
cout << "All records have been deleted" << endl;
return 1; // Return 1 for successful deletion of all records
} else {
cout << "Invalid input" << endl;
return -1; // Return -1 for invalid input
}
}

Output:

Explanation: This C++ program is a customer management system that allows users to create, view,
update, search, perform transactions, and delete customer records. The program uses a menu-driven
interface, where the user can choose options like adding new customer data, viewing all customers,
updating information, and handling transactions (deposit/withdraw). It uses an array of Person
structures to store customer details such as name, ID, address, contact number, and cash balance.
Functions are defined for each operation, and the program loops to allow continuous interaction until
the user decides to exit. Basic error handling is included for invalid inputs or when no records exist. The
program also supports deleting specific customer records or all records at once.

You might also like