Advertisement
Guest User

Untitled

a guest
May 27th, 2019
118
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.40 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<windows.h>
  4.  
  5. int i,j;
  6. int main_exit;
  7. void menu();
  8. struct date{
  9. int month,day,year;
  10.  
  11. };
  12. struct {
  13.  
  14. char name[60];
  15. int acc_no,age;
  16. char address[60];
  17. char citizenship[15];
  18. double phone;
  19. char acc_type[10];
  20. float amt;
  21. struct date dob;
  22. struct date deposit;
  23. struct date withdraw;
  24.  
  25. }add,upd,check,rem,transaction;
  26.  
  27. float interest(float t,float amount,int rate)
  28. {
  29. float SI;
  30. SI=(rate*t*amount)/100.0;
  31. return (SI);
  32.  
  33. }
  34. void fordelay(int j)
  35. { int i,k;
  36. for(i=0;i<j;i++)
  37. k=i;
  38. }
  39.  
  40. void new_acc()
  41.  
  42. {
  43. int choice;
  44. FILE *ptr;
  45.  
  46. ptr=fopen("record.dat","a+");
  47. account_no:
  48. system("cls");
  49. printf("\t\t\t\xB2\xB2\xB2\ ADD RECORD \xB2\xB2\xB2\xB2");
  50. printf("\n\n\nSaisir la date du jour(mm/dd/yyyy):");
  51. scanf("%d/%d/%d",&add.deposit.month,&add.deposit.day,&add.deposit.year);
  52. printf("\nSaisir le numero de compte:");
  53. scanf("%d",&check.acc_no);
  54. while(fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  55. {
  56. if (check.acc_no==add.acc_no)
  57. {printf("Numero de compte deja utilisé!");
  58. fordelay(1000000000);
  59. goto account_no;
  60.  
  61. }
  62. }
  63. add.acc_no=check.acc_no;
  64. printf("\nSaisir le nom:");
  65. scanf("%s",add.name);
  66. printf("\nSaisir la date de naissance(mm/dd/yyyy):");
  67. scanf("%d/%d/%d",&add.dob.month,&add.dob.day,&add.dob.year);
  68. printf("\nSaisir l'age:");
  69. scanf("%d",&add.age);
  70. printf("\nSaisir l'adresse:");
  71. scanf("%s",add.address);
  72. printf("\nEnter the citizenship number:");
  73. scanf("%s",add.citizenship);
  74. printf("\nSaisir le numero de tel: ");
  75. scanf("%lf",&add.phone);
  76. printf("\nSaisir le montant du depot:$");
  77. scanf("%f",&add.amt);
  78. printf("\nType de compte:\n\t#Sauvegarde\n\t#Current\n\t#Fixed1(for 1 year)\n\t#Fixed2(for 2 years)\n\t#Fixed3(for 3 years)\n\n\tEnter your choice:");
  79. scanf("%s",add.acc_type);
  80.  
  81. fprintf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  82.  
  83.  
  84. fclose(ptr);
  85. printf("\nAccount created successfully!");
  86. add_invalid:
  87. printf("\n\n\n\t\tEnter 1 to go to the main menu and 0 to exit:");
  88. scanf("%d",&main_exit);
  89. system("cls");
  90. if (main_exit==1)
  91. menu();
  92. else if(main_exit==0)
  93. close();
  94. else
  95. {
  96. printf("\nInvalid!\a");
  97. goto add_invalid;
  98. }
  99. }
  100. void view_list()
  101. {
  102. FILE *view;
  103. view=fopen("record.dat","r");
  104. int test=0;
  105. system("cls");
  106. printf("\nACC. NO.\tNAME\t\t\tADDRESS\t\t\tPHONE\n");
  107.  
  108. while(fscanf(view,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  109. {
  110. printf("\n%6d\t %10s\t\t\t%10s\t\t%.0lf",add.acc_no,add.name,add.address,add.phone);
  111. test++;
  112. }
  113.  
  114. fclose(view);
  115. if (test==0)
  116. { system("cls");
  117. printf("\nNO RECORDS!!\n");}
  118.  
  119. view_list_invalid:
  120. printf("\n\nEnter 1 to go to the main menu and 0 to exit:");
  121. scanf("%d",&main_exit);
  122. system("cls");
  123. if (main_exit==1)
  124. menu();
  125. else if(main_exit==0)
  126. close();
  127. else
  128. {
  129. printf("\nInvalid!\a");
  130. goto view_list_invalid;
  131. }
  132. }
  133. void edit(void)
  134. {
  135. int choice,test=0;
  136. FILE *old,*newrec;
  137. old=fopen("record.dat","r");
  138. newrec=fopen("new.dat","w");
  139.  
  140. printf("\nEnter the account no. of the customer whose info you want to change:");
  141. scanf("%d",&upd.acc_no);
  142. while(fscanf(old,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  143. {
  144. if (add.acc_no==upd.acc_no)
  145. { test=1;
  146. printf("\nWhich information do you want to change?\n1.Address\n2.Phone\n\nEnter your choice(1 for address and 2 for phone):");
  147. scanf("%d",&choice);
  148. system("cls");
  149. if(choice==1)
  150. {printf("Enter the new address:");
  151. scanf("%s",upd.address);
  152. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,upd.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  153. system("cls");
  154. printf("Changes saved!");
  155. }
  156. else if(choice==2)
  157. {
  158. printf("Enter the new phone number:");
  159. scanf("%lf",&upd.phone);
  160. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,upd.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  161. system("cls");
  162. printf("Changes saved!");
  163. }
  164.  
  165. }
  166. else
  167. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  168. }
  169. fclose(old);
  170. fclose(newrec);
  171. remove("record.dat");
  172. rename("new.dat","record.dat");
  173.  
  174. if(test!=1)
  175. { system("cls");
  176. printf("\nRecord not found!!\a\a\a");
  177. edit_invalid:
  178. printf("\nTaper 1 pour retourner au menu principal ou 0 pour quitter l'application: ");
  179. scanf("%d",&main_exit);
  180. system("cls");
  181. if (main_exit==1)
  182.  
  183. menu();
  184. else if (main_exit==2)
  185. close();
  186. else if(main_exit==0)
  187. edit();
  188. else
  189. {printf("\nInvalid!\a");
  190. goto edit_invalid;}
  191. }
  192. else
  193. {printf("\n\n\nEnter 1 to go to the main menu and 0 to exit:");
  194. scanf("%d",&main_exit);
  195. system("cls");
  196. if (main_exit==1)
  197. menu();
  198. else
  199. close();
  200. }
  201. }
  202.  
  203. void transact(void)
  204. { int choice,test=0;
  205. FILE *old,*newrec;
  206. old=fopen("record.dat","r");
  207. newrec=fopen("new.dat","w");
  208.  
  209. printf("Enter the account no. of the customer:");
  210. scanf("%d",&transaction.acc_no);
  211. while (fscanf(old,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  212. {
  213.  
  214. if(add.acc_no==transaction.acc_no)
  215. { test=1;
  216. if(strcmpi(add.acc_type,"fixed1")==0||strcmpi(add.acc_type,"fixed2")==0||strcmpi(add.acc_type,"fixed3")==0)
  217. {
  218. printf("\a\a\a\n\nYOU CANNOT DEPOSIT OR WITHDRAW CASH IN FIXED ACCOUNTS!!!!!");
  219. fordelay(1000000000);
  220. system("cls");
  221. menu();
  222.  
  223. }
  224. printf("\n\nDo you want to\n1.Deposit\n2.Withdraw?\n\nEnter your choice(1 for deposit and 2 for withdraw):");
  225. scanf("%d",&choice);
  226. if (choice==1)
  227. {
  228. printf("Enter the amount you want to deposit:$ ");
  229. scanf("%f",&transaction.amt);
  230. add.amt+=transaction.amt;
  231. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  232. printf("\n\nDeposited successfully!");
  233. }
  234. else
  235. {
  236. printf("Enter the amount you want to withdraw:$ ");
  237. scanf("%f",&transaction.amt);
  238. add.amt-=transaction.amt;
  239. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  240. printf("\n\nWithdrawn successfully!");
  241. }
  242.  
  243. }
  244. else
  245. {
  246. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  247. }
  248. }
  249. fclose(old);
  250. fclose(newrec);
  251. remove("record.dat");
  252. rename("new.dat","record.dat");
  253. if(test!=1)
  254. {
  255. printf("\n\nRecord not found!!");
  256. transact_invalid:
  257. printf("\n\n\nTaper 1 pour retourner au menu principal ou 0 pour quitter l'application: ");
  258. scanf("%d",&main_exit);
  259. system("cls");
  260. if (main_exit==0)
  261. transact();
  262. else if (main_exit==1)
  263. menu();
  264. else if (main_exit==2)
  265. close();
  266. else
  267. {
  268. printf("\nInvalid!");
  269. goto transact_invalid;
  270. }
  271.  
  272. }
  273. else
  274. {
  275. printf("\nEnter 1 to go to the main menu and 0 to exit:");
  276. scanf("%d",&main_exit);
  277. system("cls");
  278. if (main_exit==1)
  279. menu();
  280. else
  281. close();
  282. }
  283.  
  284. }
  285. void erase(void)
  286. {
  287. FILE *old,*newrec;
  288. int test=0;
  289. old=fopen("record.dat","r");
  290. newrec=fopen("new.dat","w");
  291. printf("Enter the account no. of the customer you want to delete:");
  292. scanf("%d",&rem.acc_no);
  293. while (fscanf(old,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  294. {
  295. if(add.acc_no!=rem.acc_no)
  296. fprintf(newrec,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  297.  
  298. else
  299. {test++;
  300. printf("\nRecord deleted successfully!\n");
  301. }
  302. }
  303. fclose(old);
  304. fclose(newrec);
  305. remove("record.dat");
  306. rename("new.dat","record.dat");
  307. if(test==0)
  308. {
  309. printf("\nRecord not found!!\a\a\a");
  310. erase_invalid:
  311. printf("\nTaper 1 pour retourner au menu principal ou 0 pour quitter l'application: ");
  312. scanf("%d",&main_exit);
  313.  
  314. if (main_exit==1)
  315. menu();
  316. else if (main_exit==2)
  317. close();
  318. else if(main_exit==0)
  319. erase();
  320. else
  321. {printf("\nInvalid!\a");
  322. goto erase_invalid;}
  323. }
  324. else
  325. {printf("\nEnter 1 to go to the main menu and 0 to exit:");
  326. scanf("%d",&main_exit);
  327. system("cls");
  328. if (main_exit==1)
  329. menu();
  330. else
  331. close();
  332. }
  333.  
  334. }
  335.  
  336. void see(void)
  337. {
  338. FILE *ptr;
  339. int test=0,rate;
  340. int choice;
  341. float time;
  342. float intrst;
  343. ptr=fopen("record.dat","r");
  344. printf("Do you want to check by\n1.Account no\n2.Name\nEnter your choice:");
  345. scanf("%d",&choice);
  346. if (choice==1)
  347. { printf("Enter the account number:");
  348. scanf("%d",&check.acc_no);
  349.  
  350. while (fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  351. {
  352. if(add.acc_no==check.acc_no)
  353. { system("cls");
  354. test=1;
  355.  
  356. printf("\nAccount NO.:%d\nName:%s \nDOB:%d/%d/%d \nAge:%d \nAddress:%s \nCitizenship No:%s \nPhone number:%.0lf \nType Of Account:%s \nAmount deposited:$ %.2f \nDate Of Deposit:%d/%d/%d\n\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,
  357. add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  358. if(strcmpi(add.acc_type,"fixed1")==0)
  359. {
  360. time=1.0;
  361. rate=9;
  362. intrst=interest(time,add.amt,rate);
  363. printf("\n\nYou will get $%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1);
  364. }
  365. else if(strcmpi(add.acc_type,"fixed2")==0)
  366. {
  367. time=2.0;
  368. rate=11;
  369. intrst=interest(time,add.amt,rate);
  370. printf("\n\nYou will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);
  371.  
  372. }
  373. else if(strcmpi(add.acc_type,"fixed3")==0)
  374. {
  375. time=3.0;
  376. rate=13;
  377. intrst=interest(time,add.amt,rate);
  378. printf("\n\nYou will get $.%.2f as interest on %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);
  379.  
  380. }
  381. else if(strcmpi(add.acc_type,"saving")==0)
  382. {
  383. time=(1.0/12.0);
  384. rate=8;
  385. intrst=interest(time,add.amt,rate);
  386. printf("\n\nYou will get $.%.2f as interest on %d of every month",intrst,add.deposit.day);
  387.  
  388. }
  389. else if(strcmpi(add.acc_type,"current")==0)
  390. {
  391.  
  392. printf("\n\nYou will get no interest\a\a");
  393.  
  394. }
  395.  
  396. }
  397. }
  398. }
  399. else if (choice==2)
  400. { printf("Saisir le nombre:");
  401. scanf("%s",&check.name);
  402. while (fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  403. {
  404. if(strcmpi(add.name,check.name)==0)
  405. { system("cls");
  406. test=1;
  407. printf("\nNumero de compte:%d\nNom:%s \nDOB:%d/%d/%d \nAge:%d \nAdresse:%s \nCitizenship No:%s \nPhone number:%.0lf \nType Of Account:%s \nAmount deposited:$%.2f \nDate Of Deposit:%d/%d/%d\n\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,
  408. add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  409. if(strcmpi(add.acc_type,"fixed1")==0)
  410. {
  411. time=1.0;
  412. rate=9;
  413. intrst=interest(time,add.amt,rate);
  414. printf("\n\nVous aurez $.%.2f d'interet le %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+1);
  415. }
  416. else if(strcmpi(add.acc_type,"fixed2")==0)
  417. {
  418. time=2.0;
  419. rate=11;
  420. intrst=interest(time,add.amt,rate);
  421. printf("\n\nVous aurez $.%.2f d'interet le %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+2);
  422.  
  423. }
  424. else if(strcmpi(add.acc_type,"fixed3")==0)
  425. {
  426. time=3.0;
  427. rate=13;
  428. intrst=interest(time,add.amt,rate);
  429. printf("\n\nVous aurez $.%.2f d'interet le %d/%d/%d",intrst,add.deposit.month,add.deposit.day,add.deposit.year+3);
  430.  
  431. }
  432. else if(strcmpi(add.acc_type,"saving")==0)
  433. {
  434. time=(1.0/12.0);
  435. rate=8;
  436. intrst=interest(time,add.amt,rate);
  437. printf("\n\nVous aurez $.%.2f d'interet tous les %d of every month",intrst,add.deposit.day);
  438.  
  439. }
  440. else if(strcmpi(add.acc_type,"current")==0)
  441. {
  442.  
  443. printf("\n\nVous n'aurez pas d'interet\a\a");
  444.  
  445. }
  446.  
  447. }
  448. }
  449. }
  450.  
  451.  
  452. fclose(ptr);
  453. if(test!=1)
  454. { system("cls");
  455. printf("\nCompte non trouve!!\a\a\a");
  456. see_invalid:
  457. printf("\nTaper 1 pour retourner au menu principal ou 0 pour quitter l'application: ");
  458. scanf("%d",&main_exit);
  459. system("cls");
  460. if (main_exit==1)
  461. menu();
  462. else if (main_exit==2)
  463. close();
  464. else if(main_exit==0)
  465. see();
  466. else
  467. {
  468. system("cls");
  469. printf("\nInvalide!\a");
  470. goto see_invalid;}
  471. }
  472. else
  473. {printf("\nTaper 1 pour retourner au menu principal ou 0 pour quitter l'application: ");
  474. scanf("%d",&main_exit);}
  475. if (main_exit==1)
  476. {
  477. system("cls");
  478. menu();
  479. }
  480.  
  481. else
  482. {
  483.  
  484. system("cls");
  485. close();
  486. }
  487.  
  488. }
  489.  
  490.  
  491. void menu(void)
  492. { int choice;
  493. system("cls");
  494. system("color 0");
  495. printf("\n\n\t\t\tGESTION DES COMPTES BANCAIRES");
  496. printf("\n\n\n\t\t\t\xB2\xB2\xB2\xB2\xB2\xB2\xB2 BIENVENUE DANS LE MENU PRINCIPAL \xB2\xB2\xB2\xB2\xB2\xB2\xB2");
  497. printf("\n\n\t\t1.Creer un nouveau compte\n\t\t2.Modifier les informations d'un compte\n\t\t3.Transactions\n\t\t4.Verifier les details du compte existant\n\t\t5.Supprimer un compte existant\n\t\t6.Voir la liste des clients\n\t\t7.Quitter\n\n\n\n\n\t\t Choix du menu:");
  498. scanf("%d",&choice);
  499.  
  500. system("cls");
  501. switch(choice)
  502. {
  503. case 1:new_acc();
  504. break;
  505. case 2:edit();
  506. break;
  507. case 3:transact();
  508. break;
  509. case 4:see();
  510. break;
  511. case 5:erase();
  512. break;
  513. case 6:view_list();
  514. break;
  515. case 7:close();
  516. break;
  517.  
  518. }
  519.  
  520.  
  521.  
  522. }
  523. int main()
  524. {
  525. char pass[10],password[10]="esgi";
  526. int i=0;
  527. printf("\n\n\t\tVeuillez saisir le mot de passe: ");
  528. scanf("%s",pass);
  529. /*do
  530. {
  531. //if (pass[i]!=13&&pass[i]!=8)
  532. {
  533. printf("*");
  534. pass[i]=getch();
  535. i++;
  536. }
  537. }while (pass[i]!=13);
  538. pass[10]='\0';*/
  539. if (strcmp(pass,password)==0)
  540. {printf("\n\nMot de passe correct!\nCHARGEMENT");
  541. for(i=0;i<=6;i++)
  542. {
  543. fordelay(100000000);
  544. printf(".");
  545. }
  546. system("cls");
  547. menu();
  548. }
  549. else
  550. { printf("\n\nMauvais mot de passe!!\a\a\a");
  551. login_try:
  552. printf("\nTaper 1 pour reessayer ou 0 pour quitter l'application");
  553. scanf("%d",&main_exit);
  554. if (main_exit==1)
  555. {
  556.  
  557. system("cls");
  558. main();
  559. }
  560.  
  561. else if (main_exit==0)
  562. {
  563. system("cls");
  564. close();}
  565. else
  566. {printf("\Invalide!");
  567. fordelay(1000000000);
  568. system("cls");
  569. goto login_try;}
  570.  
  571. }
  572. return 0;
  573. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement