2 ND
2 ND
h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
struct Transaction {
char type[10];
float amount;
Transaction *next;
};
struct Customer {
int id;
char name[50];
float balance;
Customer *next;
Transaction *transactions; // Pointer to store transaction history
};
void displayCustomers() {
Customer *temp = head;
while (temp != NULL) {
cout << "ID: " << temp->id << ", Name: " << temp->name << ", Balance: " <<
temp->balance << endl;
temp = temp->next;
}
}
void main() {
clrscr();
int choice, id, time;
char name[50];
float amount, principal, rate;
do {
cout << "\nBank Management System Menu:\n";
cout << "1. Add New Customer\n";
cout << "2. Display Customers\n";
cout << "3. Deposit Money\n";
cout << "4. Withdraw Money\n";
cout << "5. View Transaction History\n";
cout << "6. Calculate Compound Interest\n";
cout << "0. Exit\n";
cout << "Enter your choice: ";
cin >> choice;
switch (choice) {
case 1:
cout << "Enter ID, Name, Initial Balance: ";
cin >> id >> name >> amount;
addCustomer(id, name, amount);
break;
case 2:
displayCustomers();
break;
case 3:
cout << "Enter Customer ID and Amount to Deposit: ";
cin >> id >> amount;
deposit(id, amount);
break;
case 4:
cout << "Enter Customer ID and Amount to Withdraw: ";
cin >> id >> amount;
withdraw(id, amount);
break;
case 5:
cout << "Enter Customer ID to view transaction history: ";
cin >> id;
viewTransactionHistory(id);
break;
case 6:
cout << "Enter Principal, Rate of Interest, Time: ";
cin >> principal >> rate >> time;
float totalAmount = calculateCompoundInterest(principal, rate,
time);
cout << "Total Amount after interest: " << totalAmount << endl;
break;
case 0:
exit(0);
default:
cout << "Invalid choice! Please try again.\n";
}
} while (choice != 0);
getch();
}