Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- #include <climits>
- #include <string>
- #include <cstring>
- #include <cctype>
- #include <cassert>
- using namespace std;
- ////////////////////////////////////////
- //Declaracion de variable tipo File. //
- ////////////////////////////////////////
- ofstream salida;
- /////////////////////////////
- // Apertura de Archivo
- /////////////////////////////
- void Opening(ofstream &salida)
- {
- salida.open ("Asign4.sal");
- }
- //////////////////////////////////////////////
- // Sustitucion de COUT por archivo de salida
- //////////////////////////////////////////////
- void Display (ofstream &salida)
- {
- salida << " Los resultados son: "<< endl;
- }
- /////////////////////////////
- // Clausura de Archivo
- /////////////////////////////
- void Closing(ofstream &salida)
- {
- salida.close();
- }
- ///Llamadas de funnciones
- int clave1=4321;
- int clave2=1234;
- int balance1=4560;
- int Deposito;
- int balance;
- int retiro;
- int finalbalance;
- int username;
- int Pin;
- ///Declaracion
- bool Login(int,int);
- void Menu1(int,int);
- void Menu( int,int, int&);
- void Transacciones1( int, int, int&);
- void Transacciones2( int, int, int&);
- bool Chequeo1(int);
- bool Chequeo2(int);
- void DepositoCheque(int,int&);
- void DepositoAhorro(int,int&);
- void RetiroCheque(int,int&);
- void Ahorro(int,int&);
- void BalanceCheque(int&);
- void BalanceAhorro(int&);
- void Opening(ofstream &);
- void Closing(ofstream &);
- void Display(ofstream &);
- void Menu1(int username, int Pin)
- {
- int choose;
- Opening (salida);
- do
- {
- cout << " LOGIN" << endl;
- cout << " 1: Login " << endl;
- cout << " 2: Salir " << endl;
- cout << " 3: Display " << endl;
- cin >> choose;
- switch (choose)
- {
- case 1: Login(username,Pin);
- break;
- case 2: Closing (salida);
- cout << " Closing " << endl;
- case 3: Display (salida);
- default:;
- }
- } while (choose != 2);
- return;
- }
- bool Login(int username, int Pin)
- {
- int Attemp=0;
- // username es 4321
- // Pin # es 1234
- cout << "Inserte el nombre de usuario." << endl;
- cin >> username;
- while (username !=clave1 && Attemp<3)
- {
- cout << "Error, inserte nuevamente el nombre de usuario" << endl;
- cin >> username;
- Attemp++;
- }
- if (Attemp==3)
- {
- cout << "Se acabaron los intentos." << endl;
- return (false);
- }
- cout << "Inserte el Pin." << endl;
- cin >> Pin;
- while (Pin!=clave2 && Attemp<3)
- {
- cout <<"Error, inserte nuevamente el pin. " << endl;
- cin >> Pin;
- Attemp++;
- }
- if (Attemp==3)
- {
- cout << "Se acabaron los intentos del Pin" << endl;
- return (Attemp!=3);
- }
- Menu(Deposito,retiro,balance1);
- }
- void Menu(int Deposito, int retiro,int& balance1)
- {
- int Choose;
- do
- {
- cout << " Escoja el tipo de cuenta." << endl;
- cout << " 1: Cuenta de Cheque " << endl;
- cout << " 2: Cuenta de Ahorro " << endl;
- cout << " 3: Salir " << endl;
- cin >> Choose;
- switch (Choose)
- {
- case 1: Transacciones1(Deposito,retiro,balance1);
- break;
- case 2: Transacciones2(Deposito,retiro,balance1);
- break;
- default:;
- }
- } while (Choose != 3);
- return;
- }
- void Transacciones1( int Deposito, int retiro,int& balance1)
- {
- ////Cuenta de cheque
- int Choice;
- do
- {
- cout << "1: Deposito en cuenta de cheque " << endl;
- cout << "2: Retiro en cuenta de cheque " << endl;
- cout << "3: Balance de cuenta de cheque"<< endl;
- cout << "4: Salir" << endl;
- cin >> Choice;
- switch (Choice)
- {
- case 1: DepositoCheque(Deposito,balance1);
- break;
- case 2: RetiroCheque(retiro,balance1);
- break;
- case 3: BalanceCheque(balance1);
- break;
- default:;
- }
- } while (Choice != 4);
- return;
- }
- void Transacciones2 ( int Deposito, int retiro,int& balance1)
- {
- ////Cuenta de ahorro
- int choice;
- do
- {
- cout << "1: Deposito en cuenta de ahorro "<< endl;
- cout << "2: Ahorro en cuenta de ahorro." << endl;
- cout << "3: Balance de cuenta de ahorro" << endl;
- cout << "4: Salir" << endl;
- cin >> choice;
- switch (choice)
- {
- case 1: DepositoAhorro(Deposito,balance1);
- break;
- case 2: Ahorro(retiro,balance1);
- break;
- case 3: BalanceAhorro(balance1);
- break;
- default:;
- }
- } while (choice != 4);
- return;
- }
- bool Chequeo1 (int Deposito )
- {
- return (Deposito > 0);
- if (Chequeo1(Deposito))
- {
- cout << "Transaccion Posible" << endl;
- }
- else
- {
- cout << "Transaccion no Realizada" << endl;
- }
- }
- bool Chequeo2 (int retiro )
- {
- return (retiro > 0);
- if (Chequeo2(retiro))
- {
- cout << "Transaccion Posible" << endl;
- }
- else
- {
- cout << "Transaccion no Realizada" << endl;
- }
- }
- void DepositoCheque(int Deposito, int& balance1)
- {
- balance1=4560;
- cout << "Inserte la cantidad que desea depositar: " << endl;
- cin >> Deposito;
- while (Deposito<=0)
- {
- cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
- cin >> Deposito;
- }
- balance1= Deposito + balance1;
- }
- void DepositoAhorro(int Deposito, int& balance1)
- {
- balance1=4560;
- cout << "Inserte la cantidad que desea depositar: " << endl;
- cin >> Deposito;
- while (Deposito<=0)
- {
- cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
- cin >> Deposito;
- }
- balance1= Deposito + balance1;
- }
- void RetiroCheque(int retiro, int& balance1)
- {
- balance1=4560;
- cout << "Inserte la cantidad que desea retirar: " << endl;
- cin >> retiro;
- while (retiro<=0)
- {
- cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
- cin >> retiro;
- }
- balance1= balance1-retiro;
- }
- void Ahorro( int retiro, int& balance1)
- {
- balance1=4560;
- cout << "Inserte la cantidad que desea retirar: " << endl;
- cin >> retiro;
- while (retiro<=0)
- {
- cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
- cin >> retiro;
- }
- balance1= balance1-retiro;
- }
- void BalanceCheque(int& balance1)
- {
- balance1=balance1;
- cout << " Su balance actual es: $" << balance1 << endl;
- }
- void BalanceAhorro(int& balance1)
- {
- balance1=balance1;
- cout << " Su balance actual es: $" << balance1 << endl;
- }
- int main()
- {
- Menu1(username,Pin);
- return 0;
- }
Add Comment
Please, Sign In to add comment