Advertisement
Radoan_Ahmed

Untitled

Dec 11th, 2019
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 10.26 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<windows.h>
  4.  
  5. typedef struct data
  6. {
  7.     int acc_no,age;
  8.     char name[20];
  9.     char address[20];
  10.     char citizenship[20];
  11.     int acc_type;
  12.     double phone;
  13.     float diposit_money;
  14.     float withdraw_money;
  15.     struct data *pre;
  16.     struct data *next;
  17. } data;
  18.  
  19. data *head = NULL;
  20. data *list;
  21.  
  22. void savedata()
  23. {
  24.     list = head;
  25.     FILE *p;
  26.     fopen("project.dat","a+");
  27.     fprintf(p,"Name        account_number       address          citizenship          phone\n");
  28.     while(list != NULL)
  29.     {
  30.         fscanf(p,"%s        %d       %s          %s          %lf\n",&list->name,& list -> acc_no,& list -> address,& list ->citizenship,& list -> phone);
  31.         fprintf(p,"%s        %d       %s          %s          %lf\n",list->name, list -> acc_no, list -> address, list ->citizenship, list -> phone);
  32.     }
  33.     fclose(p);
  34. }
  35.  
  36. void view()
  37. {
  38.     int x;
  39.     list = head;
  40.     printf("name             acc_no              phone               diposit                   withdraw");
  41.     while(list != NULL)
  42.     {
  43.         printf("\n%s             %d              %0.0lf               %.2f                   %.2f",list -> name,list -> acc_no,list -> phone,list -> diposit_money, list -> withdraw_money);
  44.         list = list -> next;
  45.     }
  46.     printf("\n\n\n\t\t\tInter 1 for goto menu 0 for exit: ");
  47.     scanf("%d",&x);
  48.     if(x == 1)
  49.     {
  50.         system("cls");
  51.         menu();
  52.     }
  53.     else
  54.     {
  55.         exit_code();
  56.     }
  57. }
  58.  
  59. void exiting_acc()
  60. {
  61.     int n,accc_no,test = 0,chose;
  62.     char nam;
  63.     list = head;
  64.  
  65.     printf("Enter the account number: ");
  66.     scanf("%d",&accc_no);
  67.     while(list!=NULL)
  68.     {
  69.         if(accc_no == list -> acc_no)
  70.         {
  71.             test++;
  72.             printf("The account no: %d\n",list -> acc_no);
  73.             printf("Name: %s\n",list -> name);
  74.             printf("citizenship: %s\n",list -> citizenship);
  75.             printf("address: %s\n",list-> address);
  76.             printf("phone: %0.0lf\n",list-> phone);
  77.         }
  78.         list = list -> next;
  79.     }
  80.     if(test==0)
  81.     {
  82. add_invalid:
  83.         printf("Invalid account number: \n");
  84.         printf("Enter 1 for goto menu 0 for exit");
  85.         scanf("%d",&chose);
  86.         if(chose == 1)
  87.         {
  88.             system("cls");
  89.             menu();
  90.         }
  91.         else if(chose == 0)
  92.         {
  93.             exit_code();
  94.         }
  95.         else
  96.         {
  97.             printf("Invalid input!");
  98.             goto add_invalid;
  99.         }
  100.     }
  101.     else
  102.     {
  103.         printf("\nEnter 1 for goto manu 0 for exit");
  104.         scanf("%d",&chose);
  105.         if(chose == 1)
  106.         {
  107.             system("cls");
  108.             menu();
  109.         }
  110.         else if(chose == 0)
  111.         {
  112.             exit_code();
  113.         }
  114.     }
  115. }
  116.  
  117.  
  118. void remove_ex_acc()
  119. {
  120.     int account_number,test = 0,x;
  121.     printf("Enter account number which you want to remove: ");
  122.     scanf("%d",&account_number);
  123.     list = head;
  124.     while(list != NULL)
  125.     {
  126.         if(list -> acc_no == account_number)
  127.         {
  128.             if(list -> pre == NULL)
  129.             {
  130.                 head = list -> next;
  131.                 head -> pre = NULL;
  132.                 free(list);
  133.             }
  134.             else if(list -> next == NULL)
  135.             {
  136.                 list -> pre -> next = NULL;
  137.                 free(list);
  138.             }
  139.             else
  140.             {
  141.                 data *temp = list -> pre;
  142.                 data *temp1 = list -> next;
  143.                 temp -> next = list -> next;
  144.                 temp1 -> pre = temp;
  145.                 free(list);
  146.             }
  147.             printf("Account remove successfully");
  148.             test++;
  149.         }
  150.         list = list -> next;
  151.     }
  152.     if(test == 0)
  153.     {
  154.         printf("Invalid account number");
  155.         printf("Enter 1 for menu 0 for exit: ");
  156.         scanf("%d",&x);
  157.         if(x == 1)
  158.         {
  159.             system("cls");
  160.             menu();
  161.         }
  162.         else
  163.         {
  164.             system("cls");
  165.             exit_code();
  166.         }
  167.     }
  168.     printf("Enter 1 for menu 0 for exit: ");
  169.     scanf("%d",&x);
  170.     if(x == 1)
  171.     {
  172.         system("cls");
  173.         menu();
  174.     }
  175.     else
  176.     {
  177.         system("cls");
  178.         exit_code();
  179.     }
  180.  
  181. }
  182.  
  183.  
  184.  
  185. void tranjiction()
  186. {
  187.     int account_no, test = 0,x;
  188.     int n,money;
  189.     list = head;
  190.     printf("Enter acc.no of the customer:\n");
  191.     scanf("%d",&account_no);
  192.     while(list != NULL)
  193.     {
  194.         if(list -> acc_no == account_no)
  195.         {
  196.             test++;
  197.             printf("Do you want to\n 1.Deposit\n 2.Withdraw? ");
  198.             scanf("%d",&n);
  199.             if(n ==1)
  200.             {
  201.                 printf("Enter your amount you want to deposit: ");
  202.                 scanf("%f",&list -> diposit_money);
  203.  
  204.                 printf("Deposit successfully");
  205.                 fordelay(1000000);
  206.                 system("cls");
  207.                 menu();
  208.             }
  209.             else
  210.             {
  211.                 printf("Enter your amount you want to withdraw: ");
  212.                 scanf("%f",& list ->withdraw_money);
  213.                 printf("Withdraw successfully");
  214.                 fordelay(1000000);
  215.                 system("cls");
  216.                 menu();
  217.             }
  218.         }
  219.  
  220.         list = list -> next;
  221.     }
  222.  
  223.     if(test == 0)
  224.     {
  225.         printf("Invalid account number!\n");
  226.          printf("Enter 1 for menu 0 for exit: ");
  227.         scanf("%d",&x);
  228.         if(x == 1)
  229.         {
  230.             system("cls");
  231.             menu();
  232.         }
  233.         else
  234.         {
  235.             system("cls");
  236.             exit_code();
  237.         }
  238.  
  239.     }
  240.     printf("Enter 1 for menu 0 for exit: ");
  241.     scanf("%d",&x);
  242.     if(x == 1)
  243.     {
  244.         system("cls");
  245.         menu();
  246.     }
  247.     else
  248.     {
  249.         system("cls");
  250.         exit_code();
  251.     }
  252.  
  253.  
  254. }
  255.  
  256. void new_acc()
  257. {
  258.  
  259.     int chose;
  260.     data *N = (data*)malloc(sizeof(data));
  261.     printf("\nEnter your acc_no: ");
  262.     scanf("%d",& N -> acc_no);
  263.     printf("Enter your name: ");
  264.     scanf(" %[^\n]s",N -> name);
  265.     printf("Enter your age: ");
  266.     scanf("%d",& N -> age);
  267.     printf("Enter your address: ");
  268.     scanf(" %[^\n]s",N -> address);
  269.     printf("Enter your citizenship: ");
  270.     scanf(" %[^\n]s",N -> citizenship);
  271.     printf("Enter your phone: ");
  272.     scanf("%lf",& N -> phone);
  273.     printf("Enter your acc_type: \n\t\t\t1.Saving\n\t\t\t2.Current\n\t\t\t3.Fixed\n\n\t\tEnter your chose: ");
  274.     scanf("%d",& N -> acc_type);
  275.     N -> pre = NULL;
  276.     N -> next = NULL;
  277.     if(list == NULL)
  278.     {
  279.         list = N;
  280.         head = list;
  281.     }
  282.     else
  283.     {
  284.         list -> next = N;
  285.         N -> pre = list;
  286.         list = list -> next;
  287.     }
  288.     printf("Account create successfully!\n");
  289. add_invalid:
  290.     printf("Enter 1 for goto menu 0 for exit");
  291.     scanf("%d",&chose);
  292.     if(chose == 1)
  293.     {
  294.         system("cls");
  295.         menu();
  296.     }
  297.     else if(chose == 0)
  298.     {
  299.         exit_code();
  300.     }
  301.     else
  302.     {
  303.         printf("Invalid input!");
  304.         goto add_invalid;
  305.     }
  306. }
  307.  
  308.  
  309. void edit_acc()
  310. {
  311.  
  312.     data *temp;
  313.     int account_number,chose,test = 0,account_no,x;
  314. back:
  315.     printf("Enter the account number whose info you want to change: ");
  316.     scanf("%d",&account_no);
  317.     list = head;
  318.     while(list != NULL)
  319.     {
  320.         if(list -> acc_no == account_no)
  321.         {
  322.             test++;
  323.             printf("Which info do you want to change?\n");
  324.             printf("1.Address\n");
  325.             printf("2.Phone\n");
  326.             printf("3.Name\n");
  327.             printf("Enter your chose: ");
  328.             scanf("%d",&chose);
  329.             if(chose == 1)
  330.             {
  331.                 scanf(" %[^\n]s",list ->address);
  332.             }
  333.             else if(chose == 2)
  334.             {
  335.                 scanf("%lf",&list -> phone);
  336.             }
  337.             else
  338.             {
  339.                 scanf(" %[^\n]s",list ->name);
  340.             }
  341.             printf("Chenge saved!\n");
  342.         }
  343.         list = list -> next;
  344.     }
  345.     if(test == 0)
  346.     {
  347.         printf("Invalid account number!\a\n");
  348.         printf("Enter 1 for try again 0 for manu: ");
  349.         scanf("%d",&x);
  350.         if(x == 1)
  351.         {
  352.             system("cls");
  353.             goto back;
  354.         }
  355.         else if(x == 0)
  356.         {
  357.             system("cls");
  358.             menu();
  359.         }
  360.         else
  361.         {
  362.             system("cls");
  363.             exit_code();
  364.         }
  365.     }
  366.     else
  367.     {
  368.         printf("Your account edit succuesfully");
  369.         fordelay(100000000);
  370.         system("cls");
  371.         menu();
  372.     }
  373. }
  374.  
  375. void exit_code()
  376. {
  377.     printf("Thank you!");
  378. }
  379.  
  380. void menu()
  381. {
  382.     int chose;
  383.     system("color 7");
  384.     printf("Enter your chose\n");
  385.     printf(" 1.Create new account.\n 2.Edit account.\n 3.tranjiction.\n 4.Check the details of an exiting account.\n 5.Remove exinting account.\n 6.Vew customar list.\n 7.Exit.\n");
  386.     printf("\n\nEnter your chose: ");
  387.     scanf("%d",&chose);
  388.     switch(chose)
  389.     {
  390.     case 1:
  391.         new_acc();
  392.         break;
  393.     case 2:
  394.         edit_acc();
  395.         break;
  396.     case 3:
  397.         tranjiction();
  398.         break;
  399.     case 4:
  400.         exiting_acc();
  401.         break;
  402.     case 5:
  403.         remove_ex_acc();
  404.         break;
  405.     case 6:
  406.         view();
  407.         break;
  408.     case 7:
  409.         exit_code();
  410.         break;
  411.  
  412.     }
  413.  
  414. }
  415.  
  416. void fordelay(int n)
  417. {
  418.     int i,k;
  419.     for(i=0; i<n; i++)
  420.     {
  421.         k = i;
  422.     }
  423. }
  424.  
  425. int main()
  426. {
  427.     int n,i;
  428.     system("color 2");
  429.     char pass[10],password[10] = "prism";
  430.     printf("\n\n\t\t\t\t\t\t\Welcome To Our project\n");
  431. back:
  432.     printf("Enter your password: ");
  433.     scanf(" %[^\n]s",&pass);
  434.     system("cls");
  435.     if(strcmp(pass,password)==0)
  436.     {
  437.         printf("Password matching\n Loding");
  438.         for(i=0; i<6; i++)
  439.         {
  440.             fordelay(100000000);
  441.             printf(".");
  442.         }
  443.         system("cls");
  444.         menu();
  445.     }
  446.     else
  447.     {
  448.         printf("Incorrect password!\a\n");
  449.         printf("Enter 1 to try again 0 for exit");
  450.         scanf("%d",&n);
  451.         if(n==1)
  452.         {
  453.             system("cls");
  454.             goto back;
  455.         }
  456.         else
  457.         {
  458.             system("cls");
  459.             exit_code();
  460.         }
  461.  
  462.     }
  463.  
  464.     return 0;
  465. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement