Guest User

Untitled

a guest
Jan 23rd, 2018
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.96 KB | None | 0 0
  1. #include <fstream>
  2. #include <iostream>
  3. #include <iomanip>
  4. #include <cmath>
  5. #include <climits>
  6. #include <string>
  7. #include <cstring>
  8. #include <cctype>
  9. #include <cassert>
  10.  
  11.  
  12. using namespace std;
  13.  
  14.  
  15. ////////////////////////////////////////
  16. //Declaracion de variable tipo File. //
  17. ////////////////////////////////////////
  18. ofstream salida;
  19.  
  20. /////////////////////////////
  21. // Apertura de Archivo
  22. /////////////////////////////
  23. void Opening(ofstream &salida)
  24. {
  25. salida.open ("Asign4.sal");
  26. }
  27. //////////////////////////////////////////////
  28. // Sustitucion de COUT por archivo de salida
  29. //////////////////////////////////////////////
  30. void Display (ofstream &salida)
  31. {
  32. salida << " Los resultados son: "<< endl;
  33. }
  34. /////////////////////////////
  35. // Clausura de Archivo
  36. /////////////////////////////
  37. void Closing(ofstream &salida)
  38. {
  39. salida.close();
  40. }
  41.  
  42. ///Llamadas de funnciones
  43. int clave1=4321;
  44. int clave2=1234;
  45. int balance1=4560;
  46. int Deposito;
  47. int balance;
  48. int retiro;
  49. int finalbalance;
  50. int username;
  51. int Pin;
  52.  
  53. ///Declaracion
  54. bool Login(int,int);
  55. void Menu1(int,int);
  56. void Menu( int,int, int&);
  57. void Transacciones1( int, int, int&);
  58. void Transacciones2( int, int, int&);
  59. bool Chequeo1(int);
  60. bool Chequeo2(int);
  61. void DepositoCheque(int,int&);
  62. void DepositoAhorro(int,int&);
  63. void RetiroCheque(int,int&);
  64. void Ahorro(int,int&);
  65. void BalanceCheque(int&);
  66. void BalanceAhorro(int&);
  67.  
  68. void Opening(ofstream &);
  69. void Closing(ofstream &);
  70. void Display(ofstream &);
  71.  
  72. void Menu1(int username, int Pin)
  73. {
  74.  
  75. int choose;
  76. Opening (salida);
  77. do
  78. {
  79. cout << " LOGIN" << endl;
  80. cout << " 1: Login " << endl;
  81. cout << " 2: Salir " << endl;
  82. cout << " 3: Display " << endl;
  83. cin >> choose;
  84.  
  85. switch (choose)
  86. {
  87.  
  88. case 1: Login(username,Pin);
  89. break;
  90. case 2: Closing (salida);
  91. cout << " Closing " << endl;
  92.  
  93. case 3: Display (salida);
  94. default:;
  95. }
  96. } while (choose != 2);
  97. return;
  98. }
  99.  
  100.  
  101.  
  102.  
  103.  
  104. bool Login(int username, int Pin)
  105. {
  106. int Attemp=0;
  107. // username es 4321
  108. // Pin # es 1234
  109.  
  110.  
  111. cout << "Inserte el nombre de usuario." << endl;
  112. cin >> username;
  113. while (username !=clave1 && Attemp<3)
  114. {
  115. cout << "Error, inserte nuevamente el nombre de usuario" << endl;
  116. cin >> username;
  117. Attemp++;
  118. }
  119. if (Attemp==3)
  120. {
  121. cout << "Se acabaron los intentos." << endl;
  122. return (false);
  123. }
  124. cout << "Inserte el Pin." << endl;
  125. cin >> Pin;
  126. while (Pin!=clave2 && Attemp<3)
  127. {
  128. cout <<"Error, inserte nuevamente el pin. " << endl;
  129. cin >> Pin;
  130. Attemp++;
  131. }
  132.  
  133. if (Attemp==3)
  134. {
  135. cout << "Se acabaron los intentos del Pin" << endl;
  136. return (Attemp!=3);
  137. }
  138. Menu(Deposito,retiro,balance1);
  139.  
  140.  
  141. }
  142. void Menu(int Deposito, int retiro,int& balance1)
  143. {
  144.  
  145. int Choose;
  146. do
  147. {
  148. cout << " Escoja el tipo de cuenta." << endl;
  149. cout << " 1: Cuenta de Cheque " << endl;
  150. cout << " 2: Cuenta de Ahorro " << endl;
  151. cout << " 3: Salir " << endl;
  152. cin >> Choose;
  153.  
  154. switch (Choose)
  155. {
  156.  
  157. case 1: Transacciones1(Deposito,retiro,balance1);
  158. break;
  159. case 2: Transacciones2(Deposito,retiro,balance1);
  160. break;
  161. default:;
  162. }
  163. } while (Choose != 3);
  164. return;
  165. }
  166.  
  167. void Transacciones1( int Deposito, int retiro,int& balance1)
  168. {
  169. ////Cuenta de cheque
  170. int Choice;
  171. do
  172. {
  173. cout << "1: Deposito en cuenta de cheque " << endl;
  174. cout << "2: Retiro en cuenta de cheque " << endl;
  175. cout << "3: Balance de cuenta de cheque"<< endl;
  176. cout << "4: Salir" << endl;
  177. cin >> Choice;
  178.  
  179. switch (Choice)
  180. {
  181.  
  182. case 1: DepositoCheque(Deposito,balance1);
  183. break;
  184. case 2: RetiroCheque(retiro,balance1);
  185. break;
  186. case 3: BalanceCheque(balance1);
  187. break;
  188. default:;
  189. }
  190. } while (Choice != 4);
  191. return;
  192. }
  193.  
  194. void Transacciones2 ( int Deposito, int retiro,int& balance1)
  195. {
  196. ////Cuenta de ahorro
  197. int choice;
  198. do
  199. {
  200. cout << "1: Deposito en cuenta de ahorro "<< endl;
  201. cout << "2: Ahorro en cuenta de ahorro." << endl;
  202. cout << "3: Balance de cuenta de ahorro" << endl;
  203. cout << "4: Salir" << endl;
  204. cin >> choice;
  205.  
  206. switch (choice)
  207. {
  208. case 1: DepositoAhorro(Deposito,balance1);
  209. break;
  210. case 2: Ahorro(retiro,balance1);
  211. break;
  212. case 3: BalanceAhorro(balance1);
  213. break;
  214. default:;
  215. }
  216. } while (choice != 4);
  217. return;
  218. }
  219.  
  220. bool Chequeo1 (int Deposito )
  221. {
  222. return (Deposito > 0);
  223.  
  224. if (Chequeo1(Deposito))
  225. {
  226. cout << "Transaccion Posible" << endl;
  227. }
  228. else
  229. {
  230. cout << "Transaccion no Realizada" << endl;
  231. }
  232. }
  233.  
  234. bool Chequeo2 (int retiro )
  235. {
  236. return (retiro > 0);
  237.  
  238. if (Chequeo2(retiro))
  239. {
  240. cout << "Transaccion Posible" << endl;
  241. }
  242. else
  243. {
  244. cout << "Transaccion no Realizada" << endl;
  245. }
  246. }
  247.  
  248. void DepositoCheque(int Deposito, int& balance1)
  249. {
  250.  
  251. balance1=4560;
  252. cout << "Inserte la cantidad que desea depositar: " << endl;
  253. cin >> Deposito;
  254.  
  255. while (Deposito<=0)
  256. {
  257. cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
  258. cin >> Deposito;
  259. }
  260.  
  261. balance1= Deposito + balance1;
  262.  
  263. }
  264.  
  265. void DepositoAhorro(int Deposito, int& balance1)
  266. {
  267. balance1=4560;
  268. cout << "Inserte la cantidad que desea depositar: " << endl;
  269. cin >> Deposito;
  270.  
  271. while (Deposito<=0)
  272. {
  273. cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
  274. cin >> Deposito;
  275. }
  276.  
  277. balance1= Deposito + balance1;
  278. }
  279.  
  280. void RetiroCheque(int retiro, int& balance1)
  281. {
  282. balance1=4560;
  283. cout << "Inserte la cantidad que desea retirar: " << endl;
  284. cin >> retiro;
  285.  
  286. while (retiro<=0)
  287. {
  288. cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
  289. cin >> retiro;
  290. }
  291. balance1= balance1-retiro;
  292.  
  293. }
  294.  
  295. void Ahorro( int retiro, int& balance1)
  296. {
  297. balance1=4560;
  298. cout << "Inserte la cantidad que desea retirar: " << endl;
  299. cin >> retiro;
  300.  
  301. while (retiro<=0)
  302. {
  303. cout << "Transaccion no Realizada, inserte nuevamente el Deposito" << endl;
  304. cin >> retiro;
  305. }
  306. balance1= balance1-retiro;
  307. }
  308.  
  309. void BalanceCheque(int& balance1)
  310. {
  311. balance1=balance1;
  312. cout << " Su balance actual es: $" << balance1 << endl;
  313. }
  314. void BalanceAhorro(int& balance1)
  315. {
  316. balance1=balance1;
  317. cout << " Su balance actual es: $" << balance1 << endl;
  318. }
  319.  
  320. int main()
  321. {
  322. Menu1(username,Pin);
  323. return 0;
  324. }
Add Comment
Please, Sign In to add comment