//Update last transaction date & time
GetLocalTime(&t);
customer[customerCode].lastTxn.date = t.wDay;
customer[customerCode].lastTxn.month = t.wMonth;
customer[customerCode].lastTxn.year = t.wYear;
customer[customerCode].lastTxn.hr = t.wHour;
customer[customerCode].lastTxn.min = t.wMinute;
customer[customerCode].lastTxn.sec = t.wSecond;
printf("Withdrawal Successful. Your balance is now RM%d\n", customer[customerCode].balance);
//Rewrite customer's details into a temporary text file
for(int i = 0; i < 10; i++) {
fprintf(fptr2, "%s|%s|%s|%c|%s|%s|%s|%d|%d %d %d %d %d %d\n",
customer[i].accNo, customer[i].PIN, customer[i].name, customer[i].gender,
customer[i].address, customer[i].state, customer[i].contact,
customer[i].balance, customer[i].lastTxn.date, customer[i].lastTxn.month, customer[i].lastTxn.year,
customer[i].lastTxn.hr, customer[i].lastTxn.min, customer[i].lastTxn.sec);
}
break;
}
//Funds Transfer
case 4: {
printf("FUNDS TRANSFER\n\n");
printf("Your Balance is RM%d\n", temp.balance);
printf("Key in the Account Number of the Recipient:\t\t_____\b\b\b\b\b");
scanf("%s", &temp.accNo);
fflush(stdin);
printf("Receiver Name:%s\t\t\tAmount to Transfer:RM%d", temp.name, temp.balance);
printf("Transferred Successfully. Your balamce is now RM%d\n", customer[customerCode].balance);
//Rewrite customer's details into a temporary text file
for(int i = 0; i < 10; i++) {
fprintf(fptr2, "%s|%s|%s|%c|%s|%s|%s|%d|%d %d %d %d %d %d\n",
customer[i].accNo, customer[i].PIN, customer[i].name, customer[i].gender,
customer[i].address, customer[i].state, customer[i].contact,
customer[i].balance, customer[i].lastTxn.date, customer[i].lastTxn.month, customer[i].lastTxn.year,
customer[i].lastTxn.hr, customer[i].lastTxn.min, customer[i].lastTxn.sec);
}
break;
}
//Update last transaction date & time
GetLocalTime(&t);
customer[customerCode].lastTxn.date = t.wDay;
customer[customerCode].lastTxn.month = t.wMonth;
customer[customerCode].lastTxn.year = t.wYear;
customer[customerCode].lastTxn.hr = t.wHour;
customer[customerCode].lastTxn.min = t.wMinute;
customer[customerCode].lastTxn.sec = t.wSecond;
}
//Withdrawal Calculator
int withdrawal(int balance, int withdraw) {
int final;
final = balance - withdraw;
return final;
}
//transfers Calculator
int transfers(int balance, int transfer){
int final;
final = balance - transfer;
return final;
}
//Display Today's Date and Time
GetLocalTime(&t);
printf("\t\tDate! Today is %d/%d/%d and \n\
it's %d:%d:%d now.\n\n", t.wDay, t.wMonth, t.wYear, t.wHour, t.wMinute, t.wSecond);
A transfer is quite simple. Let's say you want to transfer 100 RM from Account A to account B.
First you need to check if account A has sufficient funds.
If yes you withdraw the amount from account A and deposit it in account B.