Está en la página 1de 6

/*SISTEMA BANCO*/ #include<conio.h> #include<string.h> #include<iostream.h> #include<ctype.h> #include<stdio.

h> #define #define #define #define #define #define NRO 4 LIM 50 MAXDNI 9 MAXSEXO 2 MAXTIPO 2 MAXCOLA 2

struct Cliente { int Nro; //char DNI[MAXDNI]; char Nombre[LIM]; int Sexo; int tipo; float monto; float Dep; float Ret; float Saldo; }; struct Nodo { Cliente C; Nodo *Sgte; }; struct ListaEn { Nodo *Cab; int N; }; //Tablas char TSexo[MAXSEXO][LIM]={"Femenino","Masculino"}; char Ttipo[MAXTIPO][LIM]={"Deposito","Retiro"}; //Lee Tabla int LeeTabla(char T[][50],int M) { int opc; for(int i=0;i<M;i++) printf("\n\t %d-%s",i+1,T[i]); do{ cout<<"\n\tIngrese Opcion: "; cin>>opc; }while(!(opc>=1 && opc<=M)); return opc; } //Zona de Prototipos int LeeEntero(char *msg,int a,int b);

int LeeFloat(char msg[],float a,float b); char Continuar(char *msg); void Inserta(ListaEn &LE,Cliente &C, Nodo *&Aux); void Inicia(ListaEn &LE); void IniciaListaEn(ListaEn &LE); void LeeListaEn(ListaEn &LE); void IniciaCliente(Cliente &C); void LeeCliente(Cliente &C); void Operaciones(Cliente &C); void Mostrar(ListaEn &LE); void MostrarCliente(Cliente &C); void Menu(ListaEn &LE); void Repor01(ListaEn &LE); void PorNumero(ListaEn &LE); void Observaciones(ListaEn &LE); void LiberarListaEn(ListaEn &LE); int LeeEntero(char *msg,int a,int b) { int num; do{ cout<<msg; cin>>num; }while(!(num>=a && num<=b)); return num; } int LeeFloat(char msg[],float a,float b) { float num; do{ cout<<msg; cin>>num; }while(!(num>=a && num<=b)); return num; } char Continuar(char *msg) { char Rpta; do{ cout<<msg; cin>>Rpta; Rpta = toupper(Rpta); }while(!(Rpta == 'S' || Rpta == 'N')); return Rpta; } main() { ListaEn LE; Inicia(LE); Menu(LE); } void Inicia(ListaEn &LE) { IniciaListaEn (LE); }

void IniciaListaEn(ListaEn &LE) { LE.Cab = NULL; LE.N = 0; } void LeeListaEn(ListaEn &LE) { Cliente C; Nodo *Aux = LE.Cab; clrscr(); cout<<"\n\n Lectura de Datos"; do { IniciaCliente(C); LeeCliente(C); Inserta(LE,C, Aux); }while(Continuar("Desea continuar (S/N):") == 'S'); } void Inserta(ListaEn &LE,Cliente &C, Nodo *&Aux) { Nodo *P; P = new Nodo; P->C = C; if(Aux == NULL) { P->Sgte = LE.Cab; LE.Cab = P; } else { P->Sgte = Aux->Sgte; Aux->Sgte = P; } LE.N++; Aux = P; } void IniciaCliente(Cliente &C) { C.Nro=0; //C.DNI[0]=NULL; C.Nombre[0]=NULL; C.Sexo=-1; C.tipo=-1, C.monto=0; C.Dep=0; C.Ret=0; C.Saldo=0.0; } void LeeCliente(Cliente &C) { //do{

cout<<"\n\tIngrese Nro: "; //fflush(stdin); cin>>C.Nro; //}while(!(strlen(C.Nro)=NRO)); cout<<"\n\tIngrese nombre:"; fflush(stdin); cin>>C.Nombre; cout<<"\n\tSexo: "; C.Sexo=LeeTabla(TSexo,MAXSEXO); cout<<"\n\tIngrese el Monto de Apertura: "; cin>>C.monto; } void Operaciones(Cliente &C) { cout<<"\n\tIngese Operacion a realizar: "; C.tipo=LeeTabla(Ttipo,MAXTIPO); if(C.tipo==1) { cout<<"\n\tIngrese el monto a Depositar: ";; cin>>C.Dep; } else { cout<<"\n\tIngrese el monto a Retirar: "; cin>>C.Ret; } C.Saldo=(C.monto+C.Dep)-C.Ret; } void Mostrar(ListaEn &LE) { clrscr(); int a=0; Nodo *Aux= LE.Cab; while(Aux!=NULL) { MostrarCliente(Aux->C); Aux=Aux->Sgte; a++; getch(); } if(a==0) { cout<<"Lista Vacia"; getch(); } } void MostrarCliente(Cliente &C) { //printf("\n\nDNI:%s",C.DNI); cout<<"\n\tNro de cuenta: "<<C.Nro; cout<<"\n\tNombre: "<<C.Nombre;

cout<<"\n\tSexo: cout<<"\n\tMonto cout<<"\n\tSaldo cout<<"\n\tSaldo cout<<"\n\tSaldo getch(); }

"<<TSexo[C.Sexo-1]; de Apertura: "<<C.monto; depositado: "<<C.Dep; retirado: "<<C.Ret; total: "<<C.Saldo;

void Menu(ListaEn &LE) { int Opc; do{ clrscr(); cout<<"\n\t\t**MENU DE OPCIONES**\n"; cout<<"\n\t[1]. Apertura Cuenta"; cout<<"\n\t[2]. Registro de Movimientos"; cout<<"\n\t[3]. Consulta Cliente"; cout<<"\n\t[4]. Mostrar Listado de Clientes"; cout<<"\n\t[5]. Mostrar Clientes Observados"; cout<<"\n\t[6]. Salir"; Opc=LeeEntero("\n\t\tIngrese Opcion: ",1,6); switch(Opc) { case 1: clrscr(); case 2: clrscr(); case 3: clrscr(); case 4: clrscr(); case 5: clrscr(); case 6: clrscr(); } }while(Opc!=6); } void Repor01(ListaEn &LE) { Nodo *Aux=LE.Cab; int cod; int sw=0; cout<<"\n\tIngrese Nro de cuenta: "; cin>>cod; cout<<"\n\t Nombre del Cliente: "<<Aux->C.Nombre; //fflush(stdin); while(Aux!=NULL) { //if(stricmp(Aux->C.Nombre,cod)==0){ if(Aux->C.Nro==cod){ Operaciones(Aux->C); sw=1; } Aux=Aux->Sgte; } if(sw==0) cout<<"\n\tNo Existe Cliente "; getch();

LeeListaEn(LE); break; Repor01(LE); break; PorNumero(LE); break; Mostrar(LE); break; Observaciones(LE);break; LiberarListaEn(LE); break;

} void PorNumero(ListaEn &LE) { Nodo *Aux=LE.Cab; int cod; int sw=0; cout<<"\n\tIngrese Nro de cuenta: "; cin>>cod; while(Aux!=NULL) { //if(stricmp(Aux->C.Nombre,cod)==0){ if(Aux->C.Nro==cod){ MostrarCliente(Aux->C); sw=1; } Aux=Aux->Sgte; } if(sw==0) cout<<"\n\tNo Existe Cliente "; getch(); } void Observaciones(ListaEn &LE) { Nodo *Aux=LE.Cab; cout<<"\n\tCLIENTES OBSERVADOS: "; if(Aux->C.Saldo<0) cout<<"\n\tNombre: "<<Aux->C.Nombre; else cout<<"\nNO HAY CLIENTES OBSERVADOS"; getch(); } void LiberarListaEn(ListaEn &LE) { clrscr(); cout<<"\n\n\t\t**SALIR DEL PROGRAMA**"; Nodo *Aux=LE.Cab; while(Aux!=NULL) { LE.Cab=Aux->Sgte; delete Aux; Aux=LE.Cab; } getch(); }

También podría gustarte