#include "file.h"
void createbank()
{
FirstB=NULL;
FirstB->FirstN=NULL;
FirstB->next=NULL;
}
void createTrans()
{
AdrNasabah P;
P=FirstB->FirstN;
P->FirstT=NULL;
}
int IsEmtyB()
{
int found;
found=0;
if (FirstB==NULL)
found=0;
else
found=1;
return(found);
}
void searchB(char nmcab[10],AdrCabBank *AdrB)
{
AdrCabBank P;
int Found=0;
P=FirstB;
while((P!=NULL) && (!Found)){
if (strcmp(P->Nama,nmcab)==0)
Found=1;
else
P=P->next;}
if (Found)
*AdrB=P;
else
*AdrB=NULL;
}
void searchN(char noN[9],AdrCabBank AdrB,AdrNasabah *AdrN)
{
AdrNasabah P;
P=AdrB->FirstN;
while((P!=NULL)&&(strcmp(P->no_rek,noN)!=0))
{P=P->next;}
if (strcmp(P->no_rek,noN)==0)
*AdrN=P;
else
*AdrN=NULL;
}
void searchNB(char noN[9],AdrCabBank AdrB,AdrNasabah *AdrN)
{
AdrCabBank P; AdrNasabah Q;
int Found=0;
P=FirstB;
Found=0;
while (P!=NULL && Found==0){
Q=AdrB->FirstN;
while((Q!=NULL)&&(strcmp(Q->no_rek,noN)!=0))
{Q=Q->next;}
if (strcmp(Q->no_rek,noN)==0){
*AdrN=Q;
Found=1;
}
else{
*AdrN=NULL;
}
P=P->next;
}
}
void insertB(char NmB[10])
{
AdrCabBank P,Q;
Q=FirstB;
P=(struct CabBank*)malloc(sizeof(struct CabBank));
strcpy(P->Nama,NmB);
P->next=NULL;
P->FirstN=NULL;
if (FirstB==NULL)
FirstB=P;
else{
while(Q->next!=NULL){Q=Q->next;}
Q->next=P;
}
}
void insertN(char noN[9],char nmN[25],AdrCabBank AdrB)
{
AdrNasabah P,Q;
Q=AdrB->FirstN;
P=(struct Nasabah*)malloc(sizeof(struct Nasabah));
strcpy(P->nama,nmN);
strcpy(P->no_rek,noN);
P->FirstT=NULL;
P->saldo=0;
P->next=NULL;
if (AdrB->FirstN==NULL)
AdrB->FirstN=P;
else{
while(Q->next!=NULL)
{
Q=Q->next;
}
Q->next=P; }
}
void deletN(AdrNasabah AdrN, AdrCabBank AdrBank)
{
AdrNasabah Q;
if (AdrN==AdrBank->FirstN)
{
AdrBank->FirstN=AdrN->next;
}
else if (AdrN->next==NULL)
{
Q=AdrBank->FirstN;
while (Q->next!=AdrN)
{
Q=Q->next;
}
Q->next=NULL;
}
else
{
Q=AdrBank->FirstN;
while (Q->next!=AdrN)
{
Q=Q->next;
}
Q->next=AdrN->next;
}
free(AdrN);
}
void Menabung(char tanggal[11],long Jml,AdrNasabah AdrN)
{
AdrTransaksi T,P;
char kd;
T=(struct Transaksi*)malloc(sizeof(struct Transaksi));
strcpy(T->date,tanggal);
T->kode=1;
T->jml=Jml;
T->next=NULL;
AdrN->saldo=AdrN->saldo +Jml;
P=AdrN->FirstT;
if (AdrN->FirstT==NULL)
AdrN->FirstT =T;
else{
while((P!=NULL)&&(P->next!=NULL))
{
P=P->next;
}
P->next=T;
}
}
void Mengambil(char tanggal[11],long Jml,AdrNasabah AdrN)
{
AdrTransaksi T,P;
char kd;
T=(struct Transaksi*)malloc(sizeof(struct Transaksi));
strcpy(T->date,tanggal);
T->kode=2;
T->jml=Jml;
if (Jml>AdrN->saldo)
{
printf(" Saldo tidak mencukupi\n");
}
else
{
AdrN->saldo=AdrN->saldo -Jml;
T->next=NULL;
P=AdrN->FirstT;
if (AdrN->FirstT==NULL)
AdrN->FirstT =T;
else{
while((P!=NULL)&&(P->next!=NULL))
{
P=P->next;
}
P->next=T;
}
}
}
void Transfer(char tanggal[11],long Jml,AdrNasabah AdrN,AdrNasabah AdrNT)
{
if (Jml<0)
{
printf("jumlah transfer tidak boleh negatif");
}
else{
if (Jml>AdrN->saldo)
{
printf("saldo tidak mencukupi");
}
else
{
Mengambil(tanggal,Jml,AdrN);
Menabung(tanggal,Jml,AdrNT);
printf("Anda melakukan transfer sbb: \n");
printf("Rekening asal : %s \n",AdrN->no_rek);
printf("Rekening tujuan : %s \n",AdrNT->no_rek);
printf("Nominal uang : %ld \n",Jml);
printf("Saldo anda tinggal : %ld \n",AdrN->saldo);
}
}
}
void Display(AdrCabBank AdrB)
{
AdrNasabah P;
P=AdrB->FirstN;
if(AdrB->FirstN==NULL)
printf("Data nasabah tak ada\n");
else{
printf("No.Rekening\tNama Nasabah\t\tSaldo\n");
while(P!=NULL)
{
printf("%s\t\t%s\t\t%ld\n",P->no_rek,P->nama,P->saldo);
P=P->next;
}
}
getch();
}
void DisplayT(AdrNasabah AdrN)
{
AdrTransaksi P;
P=AdrN->FirstT;
if(AdrN->FirstT==NULL)
printf("Data transaksi masih kosong\n");
else{
printf("Data transaksi nasabah no rek %s \n",AdrN->no_rek);
printf("Kode Transaksi\tTanggal\t\Jumlah\n");
while(P)
{
printf("%d\t\t%s\t\t% ld\n",P->kode,P->date,P->jml);
P=P->next;
}
}
getch();
}
void menu()
{
clrscr();
printf(" BANK SEDERHANA \n");
printf("------------------- \n");
printf("1. BUKA CABANG \n");
printf("2. BUKA REKENING \n");
printf("3. MENUTUP REKENING \n");
printf("4. MELAKUKAN TRANSAKSI \n");
printf("5. DISPLAY NASABAH \n");
printf("6. EXIT \n");
printf("Pilihan(1-6): \n ");
printf("PILIHAN: ");
scanf("%c",&pil);
}
void menuu()
{
clrscr();
printf("TRANSAKSI \n");
printf("1. Menabung \n");
printf("2. Mengambil Uang \n");
printf("3. Transfer \n");
printf("4. Menu utama \n");
printf("PILIHAN: ");
scanf("%c",&pil2);
}
void menuD()
{
clrscr();
printf(" DISPLAY \n");
printf("----------------\n");
printf("1. Display Nasabah\n ");
printf("2. Display Transaksi nasabah\n");
printf("3. Menu Utama \n");
printf("PILIHAN: ");
scanf("%c",&pil3);
}
Tidak ada komentar:
Posting Komentar