Advertisement
Radoan_Ahmed

Untitled

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