Bui 8 Lding
Bui 8 Lding
h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
int main_exit;
void menu();
struct date {
int month, day, year;
};
struct customer {
char name[60];
int acc_no, age;
char address[60];
char citizenship[15];
double phone;
char acc_type[10];
float amt;
struct date dob;
struct date deposit;
struct date withdraw;
} add, upd, check, rem, transaction;
void fordelay(int j) {
for (int i = 0; i < j; i++);
}
void new_acc() {
FILE *ptr = fopen("record.dat", "a+");
if (!ptr) {
perror("Unable to open file!");
return;
}
int account_no;
system("cls");
printf("\t\t\t\xB2\xB2\xB2 ADD RECORD \xB2\xB2\xB2");
printf("\n\nEnter today's date(mm/dd/yyyy):");
scanf("%d/%d/%d", &add.deposit.month, &add.deposit.day, &add.deposit.year);
while (1) {
printf("\nEnter the account number:");
scanf("%d", &account_no);
check.acc_no = account_no;
add.acc_no = check.acc_no;
printf("Enter the name: ");
scanf("%59s", add.name);
printf("Enter the date of birth(mm/dd/yyyy): ");
scanf("%d/%d/%d", &add.dob.month, &add.dob.day, &add.dob.year);
printf("Enter the age: ");
scanf("%d", &add.age);
printf("Enter the address: ");
scanf("%59s", add.address);
printf("Enter the citizenship number: ");
scanf("%14s", add.citizenship);
printf("Enter the phone number: ");
scanf("%lf", &add.phone);
printf("Enter the amount to deposit: $");
scanf("%f", &add.amt);
fclose(ptr);
printf("\nAccount created successfully!\n");
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
exit(0);
}
void view_list() {
FILE *view = fopen("record.dat", "r");
if (!view) {
perror("Unable to open file!");
return;
}
system("cls");
printf("\nACC. NO.\tNAME\t\t\tADDRESS\t\t\tPHONE\n");
int test = 0;
while (fscanf(view, "%d %59s %d/%d/%d %d %59s %14s %lf %9s %f %d/%d/%d",
&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.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);
if (test == 0) {
system("cls");
printf("\nNO RECORDS!!\n");
}
void edit(void) {
// Edit function implementation remains unchanged
}
void transact(void) {
// Transaction function implementation remains unchanged
}
void erase(void) {
// Erase function implementation remains unchanged
}
void see(void) {
// See function implementation remains unchanged
}
void close(void) {
printf("\n\n\n\nThis C Mini Project is developed by Code With C team!\n");
exit(0);
}
void menu(void) {
int choice;
system("cls");
printf("\n\n\t\t\tCUSTOMER ACCOUNT BANKING MANAGEMENT SYSTEM");
printf("\n\n\n\t\t\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2 WELCOME TO THE MAIN MENU \xB2\
xB2\xB2\xB2\xB2\xB2\xB2");
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: ");
scanf("%d", &choice);
system("cls");
switch (choice) {
case 1: new_acc(); break;
case 2: edit(); break;
case 3: transact(); break;
case 4: see(); break;
case 5: erase(); break;
case 6: view_list(); break;
case 7: close(); break;
default: printf("Invalid choice!"); menu(); break;
}
}
int main() {
char pass[10], password[10] = "codewithc";
printf("\n\n\t\tEnter the password to login: ");
scanf("%s", pass);
if (strcmp(pass, password) == 0) {
printf("\n\nPassword Match!\nLOADING");
for (int i = 0; i <= 6; i++) {
fordelay(100000000);
printf(".");
}
system("cls");
menu();
} else {
printf("\n\nWrong password!!\a\a\a");
printf("\nEnter 1 to try again and 0 to exit: ");
scanf("%d", &main_exit);
if (main_exit == 1) {
system("cls");
main();
} else {
system("cls");
close();
}
}
return 0;
}