Advertisement
Radoan_Ahmed

Untitled

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