Question: Pls explain this coding line by line #include #include #include #include int i,j; int main_exit; void menu(); int atm(); void close(); struct date{ int month,day,year;

Pls explain this coding line by line #include #include #include #include int i,j; int main_exit; void menu(); int atm(); void close(); struct date{ int month,day,year; }; 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; struct date deposit; struct date withdraw;

}add,upd,check,rem,transaction;

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

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

void new_acc()

{ int choice; FILE *ptr;

ptr=fopen("record.dat","a+"); account_no: system("cls"); printf("\t\t\t==== ADD RECORD ===="); printf(" Enter today's date(mm/dd/yyyy):"); scanf("%d/%d/%d",&add.deposit.month,&add.deposit.day,&add.deposit.year); printf(" Enter the account number:"); scanf("%d",&check.acc_no); while(fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %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) { if (check.acc_no==add.acc_no) {printf("Account no. already in use!"); fordelay(1000000000); goto account_no;

} } add.acc_no=check.acc_no; printf(" Enter the name:"); scanf("%s",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("%s",add.address); printf(" Enter the citizenship number:"); scanf("%s",add.citizenship); printf(" Enter the phone number: "); scanf("%lf",&add.phone); printf(" Enter the amount to deposit:$"); scanf("%f",&add.amt); printf(" Type of account: \t#Saving \t#Current \t#Fixed1(for 1 year) \t#Fixed2(for 2 years) \t#Fixed3(for 3 years) \tEnter your choice:"); scanf("%s",add.acc_type);

fprintf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %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);

fclose(ptr); printf(" Account created successfully!"); add_invalid: printf(" \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(" Invalid!\a"); goto add_invalid; } } void view_list() { FILE *view; view=fopen("record.dat","r"); int test=0; system("cls"); printf(" ACC. NO.\tNAME\t\t\tADDRESS\t\t\tPHONE ");

while(fscanf(view,"%d %s %d/%d/%d %d %s %s %lf %s %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(" %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(" NO RECORDS!! ");}

view_list_invalid: printf(" Enter 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(" Invalid!\a"); goto view_list_invalid; } } void edit(void) { int choice,test=0; FILE *old,*newrec; old=fopen("record.dat","r"); newrec=fopen("new.dat","w");

printf(" Enter the account no. of the customer whose info you want to change:"); scanf("%d",&upd.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.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) { if (add.acc_no==upd.acc_no) { test=1; printf(" Which information do you want to change? 1.Address 2.Phone Enter your choice(1 for address and 2 for phone):"); scanf("%d",&choice); system("cls"); if(choice==1) {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 ",add.acc_no,add.name,add.dob.month,add.dob.day,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) { 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 ",add.acc_no,add.name,add.dob.month,add.dob.day,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 fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %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); } fclose(old); fclose(newrec); remove("record.dat"); rename("new.dat","record.dat");

if(test!=1) { system("cls"); printf(" Record not found!!\a\a\a"); edit_invalid: printf(" Enter 0 to try again,1 to return to main menu and 2 to exit:"); scanf("%d",&main_exit); system("cls"); if (main_exit==1)

menu(); else if (main_exit==2) close(); else if(main_exit==0) edit(); else {printf(" Invalid!\a"); goto edit_invalid;} } else {printf(" Enter 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 transact(void) { int choice,test=0; 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.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) {

if(add.acc_no==transaction.acc_no) { test=1; if(strcmpi(add.acc_type,"fixed1")==0||strcmpi(add.acc_type,"fixed2")==0||strcmpi(add.acc_type,"fixed3")==0) { printf("\a\a\a YOU CANNOT DEPOSIT OR WITHDRAW CASH IN FIXED ACCOUNTS!!!!!"); fordelay(1000000000); system("cls"); menu();

} printf(" Do you want to 1.Deposit 2.Withdraw? Enter your choice(1 for deposit and 2 for withdraw):"); scanf("%d",&choice); if (choice==1) { printf("Enter the amount you want to deposit:$ "); scanf("%f",&transaction.amt); add.amt+=transaction.amt; fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %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); printf(" Deposited successfully!"); } else { printf("Enter the amount you want to withdraw:$ "); scanf("%f",&transaction.amt); add.amt-=transaction.amt; fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %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); printf(" Withdrawn successfully!"); }

} else { fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %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); } } fclose(old); fclose(newrec); remove("record.dat"); rename("new.dat","record.dat"); if(test!=1) { printf(" Record not found!!"); transact_invalid: printf(" Enter 0 to try again,1 to return to 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(" Invalid!"); goto transact_invalid; }

} else { printf(" Enter 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"); newrec=fopen("new.dat","w"); 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.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) { if(add.acc_no!=rem.acc_no) fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %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);

else {test++; printf(" Record deleted successfully! "); } } fclose(old); fclose(newrec); remove("record.dat"); rename("new.dat","record.dat"); if(test==0) { printf(" Record not found!!\a\a\a"); erase_invalid: printf(" Enter 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(" Invalid!\a"); goto erase_invalid;} } else {printf(" Enter 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"); printf("Do you want to check by 1.Account no 2.Name Enter your choice:"); scanf("%d",&choice); if (choice==1) { printf("Enter the account number:"); scanf("%d",&check.acc_no);

while (fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %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) { if(add.acc_no==check.acc_no) { system("cls"); test=1;

printf(" Account NO.:%d Name:%s DOB:%d/%d/%d Age:%d Address:%s Citizenship No:%s Phone number:%.0lf Type Of Account:%s Amount deposited:$ %.2f Date Of Deposit:%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); if(strcmpi(add.acc_type,"fixed1")==0) { time=1.0; rate=9; intrst=interest(time,add.amt,rate); printf(" You will get $%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1); } else if(strcmpi(add.acc_type,"fixed2")==0) { time=2.0; rate=11; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);

} else if(strcmpi(add.acc_type,"fixed3")==0) { time=3.0; rate=13; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);

} else if(strcmpi(add.acc_type,"saving")==0) { time=(1.0/12.0); rate=8; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d of every month",intrst,add.deposit.day);

} else if(strcmpi(add.acc_type,"current")==0) {

printf(" You will get no interest\a\a");

}

} } } else if (choice==2) { printf("Enter the name:"); scanf("%s",&check.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.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) { if(strcmpi(add.name,check.name)==0) { system("cls"); test=1; printf(" Account No.:%d Name:%s DOB:%d/%d/%d Age:%d Address:%s Citizenship No:%s Phone number:%.0lf Type Of Account:%s Amount deposited:$%.2f Date Of Deposit:%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); if(strcmpi(add.acc_type,"fixed1")==0) { time=1.0; rate=9; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1); } else if(strcmpi(add.acc_type,"fixed2")==0) { time=2.0; rate=11; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);

} else if(strcmpi(add.acc_type,"fixed3")==0) { time=3.0; rate=13; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);

} else if(strcmpi(add.acc_type,"saving")==0) { time=(1.0/12.0); rate=8; intrst=interest(time,add.amt,rate); printf(" You will get $.%.2f as interest on %d of every month",intrst,add.deposit.day);

} else if(strcmpi(add.acc_type,"current")==0) {

printf(" You will get no interest\a\a");

}

} } }

fclose(ptr); if(test!=1) { system("cls"); printf(" Record not found!!\a\a\a"); see_invalid: printf(" Enter 0 to try again,1 to return to main menu and 2 to exit:"); scanf("%d",&main_exit); system("cls"); if (main_exit==1) menu(); else if (main_exit==2) close(); else if(main_exit==0) see(); else { system("cls"); printf(" Invalid!\a"); goto see_invalid;} } else {printf(" Enter 1 to go to the main menu and 0 to exit:"); scanf("%d",&main_exit);} if (main_exit==1) { system("cls"); menu(); }

else {

system("cls"); close(); }

}

void close(void) { printf(" Brought To You by code-projects.org"); }

void menu(void) { int choice; system("cls"); system("color 7"); printf(" \t\t\t BANKING MANAGEMENT SYSTEM"); printf(" \t\t\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2 WELCOME TO THE MAIN MENU \xB2\xB2\xB2\xB2\xB2\xB2\xB2"); printf(" \t\t[1] Create a new account \t\t[2] Update information of existing account \t\t[3] Transactions \t\t[4] Check the details of existing account \t\t[5] Remove existing account \t\t[6] View customer's list \t\t[7] ATM Feature \t\t[8] Exit \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:atm(); break; case 8:close(); break; }

} int main() { char pass[10],password[10]="pass"; int i=0; printf(" \t\t\t\t Bank Management System \t\t\t\t\t User Login "); printf(" \t\t\t\tEnter the password to login:"); scanf("%s",pass); /*do { //if (pass[i]!=13&&pass[i]!=8) { printf("*"); pass[i]=getch(); i++; } }while (pass[i]!=13); pass[10]='\0';*/ if (strcmp(pass,password)==0) {printf(" Password Match! LOADING"); for(i=0;i<=6;i++) { fordelay(100000000); printf(". "); } printf(" "); system("pause"); system("cls"); menu(); } else { printf(" Wrong password!!\a\a\a"); login_try: printf(" Enter 1 to try again and 0 to exit:"); scanf("%d",&main_exit); if (main_exit==1) {

system("cls"); main(); }

else if (main_exit==0) { system("cls"); close();} else {printf(" Invalid!"); fordelay(1000000000); system("cls"); goto login_try;}

} return 0; }

//ATM FEATURE - nsb code-projects int atm(){ //Functions

void mainMenu(); void checkBalance(float balance); float moneyDeposit(float balance); float moneyWithdraw(float balance); void menuExit(); void errorMessage();

int login(void) { float number = 1234; int pass; printf(" \t\t\tEnter the PIN No:"); scanf("%d", &pass);

if (pass == number) { printf(" PIN Matched! LOADING"); for(i=0;i<=6;i++) { fordelay(100000000); printf("."); } system("cls"); mainMenu(); } else { printf("Invalid Try Again"); login(); } return 0; }

//Main Code //Local Declarations int option; float balance = 15000.00; int choose; bool again = true; // insert code here... login(); while (again) { printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- "); printf("Your Selection:\t"); scanf("%d", &option); system("CLS"); switch (option) { case 1: checkBalance(balance); break; case 2: balance = moneyDeposit(balance); break; case 3: balance = moneyWithdraw(balance); break; case 4: menuExit(); return 0; default: errorMessage(); break; } printf("=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= "); printf("Would you like to do another transaction: "); printf("< 1 > Yes "); printf("< 2 > No "); scanf("%d", &choose); system("CLS"); if (choose == 2) { again = false; menuExit(); }else{ mainMenu(); } }

return 0; }//main code

//Functions

void mainMenu() { printf(" \t\t==========Welcome to ATM Feature========== "); printf(" \t\t----Please choose one of the options below---- "); printf(" \t\t< 1 > Check Balance "); printf(" \t\t< 2 > Deposit "); printf(" \t\t< 3 > Withdraw "); printf(" \t\t< 4 > Exit "); }//Main Menu

void checkBalance(float balance) { printf("You Choose to See your Balance "); printf("****Your Available Balance is: $%.2f ", balance); }//Check Balance

float moneyDeposit(float balance) { float deposit; printf("You choose to Deposit a money "); printf("$$$$Your Balance is: $%.2f ", balance); printf("****Enter your amount to Deposit "); scanf("%f", &deposit); balance += deposit; printf("****Your New Balance is: $%.2f ", balance); return balance; }//money deposit

float moneyWithdraw(float balance) { float withdraw; bool back = true; printf("You choose to Withdraw a money "); printf("$$$$Your Balance is: $%.2f ", balance); while (back) { printf("Enter your amount to withdraw: "); scanf("%f", &withdraw); if (withdraw < balance) { back = false; balance -= withdraw; printf("$$$$Your withdrawing money is: $%.2f ", withdraw); printf("****Your New Balance is: $%.2f ", balance); } else { printf("+++You don't have enough money+++ "); printf("Please contact to your Bank Customer Services "); printf("****Your Balance is: $%.2f ", balance); } } return balance; }//money withdraw

void menuExit() { printf("--------------Take your receipt!!!------------------ "); printf("-----Thank you for using ATM Banking Machine!!!----- "); printf("----- Brought To by code-projects.org ----- "); }//exit menu

void errorMessage() {; printf("+++!!!You selected invalid number!!!+++ "); }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!