Advertisement
Radoan_Ahmed

Untitled

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