Advertisement
Guest User

Untitled

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