Advertisement
Radoan_Ahmed

Untitled

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