#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<time.h>
/* run this
program using the console pauser or add your own getch,
system("pause") or input loop */
struct
Account {
int SoTK;
char tenCTK[50];
int mapin;
int sodu;
char timetrasaction[100];
};
void menu(){
printf("\n------Dang Kiem tra thong
Tin---------");
printf("\n==============================");
printf("\nXin
chào mung Nguyen Gia Vinh");
printf("\n-
1. Kiem tra so du tai khoan");
printf("\n-
2. Rut tien");
printf("\n-
3. Chuyen khoan");
printf("\n-
4. Doi ma pin");
printf("\n- 0. Ket thuc giao dich
");
}
void
menu1(){
printf("\n==============================");
printf("\nXin
chào mung Nguyen Gia Vinh");
printf("\n-
1. Kiem tra so du tai khoan");
printf("\n-
2. Rut tien");
printf("\n-
3. Chuyen khoan");
printf("\n-
4. Doi ma pin");
printf("\n- 0. Ket thuc giao dich
");
}
char
printAccountInfo(struct Account vinh){
char choiceContinue;
printf("\nSo du trong tai khoan la:
%d",vinh.sodu);
printf("\nLan giao dich gan
nhat:%s", vinh.timetrasaction);
char a;
printf("\nBan co muon in
phieu ? (Y/N): ");
scanf("\n%c",&a);fflush(stdin);
if(a=='y'){
printf("\n...Dang
in....");
printf("\n...Xong.......");
}
printf("\nBan co muon tiep
tuc giao dich ? (Y/N): ");
scanf("\n%c",&choiceContinue);fflush(stdin);
return choiceContinue;
}
char
takeMoney(){
char choiceContinue;
printf("\nSo du trong tai
khoan la 10000000");
printf("\nNhap so tien can
rut: ");
int sotien1;
scanf("%d",&sotien1);fflush(stdin);
char e;
printf("\nBan co muon rut
so tien nay (Y/N): ");
scanf("\n%c",&e);fflush(stdin);
if(e=='y'){
printf("\n...Dang
thuc hien rut tien....");
printf("\n...Xong.......");
printf("\nSo
du trong tai khoan cua ban la: %d",10000000-sotien1);
printf("\nBan
co muon in phieu ? (Y/N): ");
char f;
scanf("\n%c",&f);fflush(stdin);
if(f=='y'){
printf("\n...Dang
in....");
printf("\n...Xong.......");
}
}
printf("\nBan
co muon tiep tuc giao dich ? (Y/N): ");
scanf("%c",&choiceContinue);fflush(stdin);
return
choiceContinue;
}
char
transferMoney(){
char
choiceContinue;
printf("\nSo
du trong tai khoan cua ban: 10000000");
printf("\nNhap
tai khoan muon chuyen: ");
int
taikhoan;
scanf("%d",&taikhoan);fflush(stdin);
printf("\nNhap
so tien muon chuyen: ");
int sotien;
scanf("%d",&sotien);fflush(stdin);
char c;
printf("\nBan
co muon chuyen so tien nay (Y/N): ");
scanf("\n%c",&c);fflush(stdin);
if(c=='y'){
printf("\n...Dang thuc hien
dao dich....");
printf("\n...Xong.......");
printf("\nSo du trong tai
khoan cua ban la: %d",10000000-sotien);
printf("\nBan co muon in
phieu ? (Y/N): ");
char d;
scanf("\n%c",&d);fflush(stdin);
if(d=='y'){
printf("\n...Dang
in....");
printf("\n...Xong.......");
}
}
printf("\nBan co muon tiep tuc giao
dich ? (Y/N): ");
scanf("%c",&choiceContinue);fflush(stdin);
return choiceContinue;
}
char
changePass(){
char choiceContinue;
printf("\nNhap ma pin hien
tai: ");
int p;
scanf("%d",&p);fflush(stdin);
if(p!=123456){
do{
printf("\nNhap
ma sai-Xin moi nhap lai ma pin hien tai: ");
scanf("%d",&p);fflush(stdin);
if(p==123456){
printf("\nNhap
ma pin moi: ");
int p1;
scanf("%d",&p1);fflush(stdin);
printf("\nNhap lai ma pin
moi: ");
int p2;
scanf("%d",&p2);fflush(stdin);
if(p1!=p2){
do{
printf("\nNhap
ma sai-Xin moi nhap lai ma pin moi: ");
scanf("%d",&p2);fflush(stdin);
if(p1==p2){
printf("\n...Dang
doi ma PIN...");
printf("\n...Xong......................");
printf("\nBan
co muon tiep tuc giao dich ? (Y/N): ");
}
}while(p1!=p2);
}else{
printf("\n...Dang
doi ma PIN...");
printf("\n...Xong......................");
printf("\nBan
co muon tiep tuc giao dich ? (Y/N): ");
}
}
}while(p!=123456);
}else{
printf("\nNhap ma pin moi:
");
int p1;
scanf("%d",&p1);fflush(stdin);
printf("\nNhap lai ma pin
moi: ");
int p2;
scanf("%d",&p2);fflush(stdin);
if(p1!=p2){
do{
printf("\nNhap
ma sai-Xin moi nhap lai ma pin moi: ");
scanf("%d",&p2);fflush(stdin);
if(p1==p2){
printf("\n...Dang
doi ma PIN...");
printf("\n...Xong......................");
}
}while(p1!=p2);
}else{
printf("\n...Dang
doi ma PIN...");
printf("\n...Xong......................");
}
printf("\nBan co muon tiep tuc giao dich
? (Y/N): ");
scanf("%c",&choiceContinue);fflush(stdin);
return choiceContinue;
}
}
int main(int
argc, char *argv[]) {
//get current time
time_t rawtime;
struct
tm *timeinfo;
time
( &rawtime );
timeinfo
= localtime ( &rawtime );
struct Account vinh;
strcpy(vinh.timetrasaction,asctime
(timeinfo));
vinh.mapin=123456;
vinh.sodu=10000000;
printf("========================Ngan
hang FPT Aptech==============================");
printf(" -------------Hay dua the cua ban
vao------------- ");
printf(" \nXin moi nhap ma
pin: ");
scanf("%d",&vinh.mapin);fflush(stdin);
if (vinh.mapin!=123456){
do{
printf("\nXin
moi nhap lai ma pin: ");
scanf("%d",&vinh.mapin);fflush(stdin);
if(vinh.mapin==123456){
menu();
}
} while
(vinh.mapin!=123456);
}
else {
menu();
}
int luachon;
char choiceContinue;
while(choiceContinue !='n' ||
choiceContinue != 'N'){
printf("\nXin
moi nhap lua chon: ");
scanf("%d",&luachon);fflush(stdin);
if(luachon==1){
choiceContinue=
printAccountInfo(vinh);
menu1();
}else
if(luachon==2){
choiceContinue
= takeMoney();
menu1();
}else
if(luachon==3){
choiceContinue
= transferMoney();
menu1();
}else if(luachon==4){
choiceContinue
= changePass();
menu1();
}else
if(luachon==0){
printf("\nKet
thuc giao dich");
break;
}
}
return 0;
}
Nhận xét
Đăng nhận xét