Advertisement
Guest User

Untitled

a guest
Nov 24th, 2014
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.07 KB | None | 0 0
  1. #include<windows.h>
  2. #include<stdio.h>
  3. #include<dos.h>
  4. #include<stdlib.h>
  5. #include<math.h>
  6. #include<iostream>
  7. using namespace std;
  8. int main()
  9. {
  10. int choice322,loop=0,loop2,loop3,i,pass,choice=1;
  11. char first2[50],middle2[50],last2[50],account1[50];
  12. char first1[50][50],middle1[50][50],last1[50][50],search[50],account[50][50];
  13. float initial[50],deposit,withdraw,initial2;
  14.  
  15.  
  16. intro:
  17. system("CLS");
  18. printf("Bank System\n\n\n");
  19. printf("1. Add Accounts\n");
  20. printf("2. View Accounts\n");
  21. printf("3. Deposit\n");
  22. printf("4. Withdraw\n");
  23. printf("5. Exit\n");
  24. scanf("%d",&choice);
  25.  
  26.  
  27.  
  28. switch(choice)
  29. {
  30.  
  31. case 1:
  32.  
  33. system("CLS");
  34. for(;loop<50;)
  35. {
  36. printf("Account #: ");fflush(stdin);
  37. gets(account[loop]);
  38. printf("\nFirst Name: ");fflush(stdin);
  39. /*scanf("%s", &first1[loop]);*/
  40. gets(first1[loop]);
  41. printf("\nMiddle Name: ");
  42. /*scanf("%s", &middle1[loop]);*/
  43. gets(middle1[loop]);
  44. printf("\nLast Name: ");
  45. gets(last1[loop]);
  46. printf("\nInitial Deposit: ");
  47. scanf("%f", &initial[loop]);
  48. loop++;
  49. break;
  50.  
  51. }
  52. goto intro;
  53. case 2:
  54. system("CLS");
  55. printf("1. Single Account\n");
  56. printf("2. All Accounts");
  57. scanf("%d", &choice322);
  58.  
  59. if (choice322 == 1)
  60. {
  61. goto Single;
  62. }
  63. else if (choice322 == 2)
  64. {
  65. goto All;
  66. }
  67. break;
  68.  
  69. case 3:
  70. system("CLS");
  71. printf("Search Account #: ");fflush(stdin);
  72. gets(search);
  73.  
  74.  
  75. for (loop2=0; loop2<loop; loop2++)
  76. {
  77. /*if(account[loop] == search[loop])*/
  78. if(strcmp(account[loop2],search) == 0)
  79. {
  80. printf("Enter amount to deposit: ");
  81. scanf("%f", &deposit);
  82. initial[loop2]+=deposit;
  83. printf("Your current money is %.2f",initial[loop2]);
  84. getchar();
  85. /*getch();*/
  86. system("CLS");
  87. goto intro;
  88. }
  89. /*else if (account[loop] != search[loop])*/
  90. /* if(strcmp(account[loop2],search) != 0)*/
  91. }
  92. printf("\n Account number not found.");
  93. getchar();
  94. system("CLS");
  95. goto intro;
  96.  
  97.  
  98.  
  99. break;
  100.  
  101.  
  102.  
  103. case 4:
  104. system("CLS");
  105. printf("Search Account #: ");fflush(stdin);
  106. gets(search);
  107.  
  108.  
  109. for (loop2=0; loop2<loop;loop2++)
  110. {
  111.  
  112. if(strcmp(account[loop2],search) == 0)
  113. {
  114. printf("Enter amount to withdraw: ");
  115. scanf("%f",&withdraw);
  116. initial[loop2]-=withdraw;
  117. printf("Your current money is now %.2f",initial[loop2]);
  118. getchar();
  119. /*getch();*/
  120. system("CLS");
  121. goto intro;
  122. }
  123. }
  124. /* else if(strcmp(account[loop2],search) != 0)*/
  125.  
  126. printf("\n Account number not found.");
  127. getchar();
  128. system("CLS");
  129. goto intro;
  130.  
  131. break;
  132.  
  133. case 5:
  134.  
  135. {
  136. exit(0);
  137. }
  138. default:
  139. {
  140. goto intro;
  141. }
  142.  
  143. }
  144.  
  145.  
  146. Single:
  147. system("CLS");
  148. printf("Search Account #: ");fflush(stdin);
  149. gets(search);
  150. //cout<<"loop"<<loop;
  151. for(loop2=0;loop2<loop;loop2++)
  152.  
  153. {
  154. if(strcmp(search,account[loop2])== 0)
  155.  
  156. { printf("\nAccount #: ");fflush(stdin);
  157. puts(account[loop2]);
  158. printf("\n\nFirst Name: ");
  159. puts(first1[loop2]);
  160. printf("\n\nMiddle Name: ");
  161. puts(middle1[loop2]);
  162. printf("\n\nLast Name: ");
  163. puts(last1[loop2]);
  164. printf("\n\nInitial Deposit: %.2f", initial[loop2]);fflush(stdin);
  165. //getch();
  166. getchar();
  167. system("CLS");
  168. goto intro;
  169. }
  170. }
  171. printf("\n Account number not found.");
  172. getchar();
  173. system("CLS");
  174. goto intro;
  175.  
  176. All:
  177. system("CLS");
  178. for(pass = 0; pass<loop; pass++)
  179. {
  180. for(i=pass + 1; i<loop; i++)
  181. {
  182. if(strcmp(account[pass],account[i])>0)
  183. {
  184. strcpy(account1,account[pass]);
  185. strcpy(account[pass],account[i]);
  186. strcpy(account[i],account1);
  187.  
  188. strcpy(first2,first1[pass]);
  189. strcpy(first1[pass],first1[i]);
  190. strcpy(first1[i],first2);
  191.  
  192. strcpy(middle2,middle1[pass]);
  193. strcpy(middle1[pass],middle1[i]);
  194. strcpy(middle1[i],middle2);
  195.  
  196. strcpy(last2,last1[pass]);
  197. strcpy(last1[pass],last1[i]);
  198. strcpy(last1[i],last2);
  199.  
  200. initial2 = initial[pass];
  201. initial[pass]=initial[i];
  202. initial[i]=initial2;
  203.  
  204.  
  205. }
  206. }
  207. }
  208. for(loop3=0; loop3<loop; loop3++)
  209. {
  210. printf("Account #: ");fflush(stdin);
  211. puts(account[loop3]);
  212. printf("\n\nFirst Name: ");
  213. puts(first1[loop3]);
  214. printf("\n\nMiddle Name: ");
  215. puts(middle1[loop3]);
  216. printf("\n\nLast Name: ");
  217. puts(last1[loop3]);
  218. printf("\n\nInitial Deposit: %.2f",initial[loop3]);
  219. printf("\n\n\n\n");
  220. }
  221.  
  222. getchar();
  223. system("CLS");
  224. goto intro;
  225. return 0;
  226. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement