4 TH
4 TH
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;
}
}
if (trans == NULL) {
cout << "No transactions found." << endl;
return;
}
void main() {
clrscr();
int choice, id, time;
char name[50];
char amountStr[20], principalStr[20], rateStr[20];
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 >> amountStr;
addCustomer(id, name, convertToFloat(amountStr));
break;
case 2:
displayCustomers();
break;
case 3:
cout << "Enter Customer ID and Amount to Deposit: ";
cin >> id >> amountStr;
deposit(id, convertToFloat(amountStr));
break;
case 4:
cout << "Enter Customer ID and Amount to Withdraw: ";
cin >> id >> amountStr;
withdraw(id, convertToFloat(amountStr));
break;
case 5:
cout << "Enter Customer ID to view transaction history: ";
cin >> id;
viewTransactionHistory(id); // No longer prompts for number of
transactions
break;
case 6:
cout << "Enter Principal, Rate of Interest, Time: ";
cin >> principalStr >> rateStr >> time;
float totalAmount =
calculateCompoundInterest(convertToFloat(principalStr), convertToFloat(rateStr),
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();
}