Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- #include<windows.h>
- typedef struct data
- {
- int acc_no,age;
- char name[20];
- char address[20];
- char citizenship[20];
- int acc_type;
- double phone;
- float diposit_money;
- float withdraw_money;
- struct data *pre;
- struct data *next;
- } data;
- data *head = NULL;
- data *list;
- data *temp;
- void savedata()
- {
- list = head;
- FILE *ptr;
- fopen("project.dat","a+");
- while(list != NULL)
- {
- fprintf(ptr,"Name account_number address citizenship phone\n");
- fprintf(ptr,"%s %d %s %s %lf\n",list->name, list -> acc_no, list -> address, list ->citizenship, list -> phone);
- list = list -> next;
- }
- fclose(p);
- }
- void view()
- {
- int x;
- list = head;
- printf("name acc_no phone diposit withdraw");
- while(list != NULL)
- {
- printf("\n%s %d %0.0lf %.2f %.2f",list -> name,list -> acc_no,list -> phone,list -> diposit_money, list -> withdraw_money);
- list = list -> next;
- }
- printf("\n\n\n\t\t\tInter 1 for goto menu 0 for exit: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- menu();
- }
- else
- {
- exit_code();
- }
- }
- void exiting_acc()
- {
- int n,accc_no,test = 0,chose;
- char nam;
- list = head;
- printf("Enter the account number: ");
- scanf("%d",&accc_no);
- while(list!=NULL)
- {
- if(accc_no == list -> acc_no)
- {
- test++;
- printf("The account no: %d\n",list -> acc_no);
- printf("Name: %s\n",list -> name);
- printf("citizenship: %s\n",list -> citizenship);
- printf("address: %s\n",list-> address);
- printf("phone: %0.0lf\n",list-> phone);
- }
- list = list -> next;
- }
- if(test==0)
- {
- add_invalid:
- printf("Invalid account number: \n");
- printf("Enter 1 for goto menu 0 for exit");
- scanf("%d",&chose);
- if(chose == 1)
- {
- system("cls");
- menu();
- }
- else if(chose == 0)
- {
- exit_code();
- }
- else
- {
- printf("Invalid input!");
- goto add_invalid;
- }
- }
- else
- {
- printf("\nEnter 1 for goto manu 0 for exit");
- scanf("%d",&chose);
- if(chose == 1)
- {
- system("cls");
- menu();
- }
- else if(chose == 0)
- {
- exit_code();
- }
- }
- }
- void remove_ex_acc()
- {
- int account_number,test = 0,x;
- printf("Enter account number which you want to remove: ");
- scanf("%d",&account_number);
- list = head;
- while(list != NULL)
- {
- if(list -> acc_no == account_number)
- {
- if(list -> pre == NULL)
- {
- head = list -> next;
- head -> pre = NULL;
- free(list);
- }
- else if(list -> next == NULL)
- {
- temp = list -> pre;
- temp -> next = NULL;
- free(list);
- }
- else
- {
- data *temp = list -> pre;
- data *temp1 = list -> next;
- temp -> next = temp1;
- temp1 -> pre = temp;
- free(list);
- }
- printf("Account remove successfully");
- test++;
- }
- list = list -> next;
- }
- if(test == 0)
- {
- printf("Invalid account number");
- printf("Enter 1 for menu 0 for exit: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- menu();
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- printf("Enter 1 for menu 0 for exit: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- menu();
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- void tranjiction()
- {
- int account_no, test = 0,x;
- int n,money;
- list = head;
- printf("Enter acc.no of the customer:\n");
- scanf("%d",&account_no);
- while(list != NULL)
- {
- if(list -> acc_no == account_no)
- {
- test++;
- printf("Do you want to\n 1.Deposit\n 2.Withdraw? ");
- scanf("%d",&n);
- if(n ==1)
- {
- printf("Enter your amount you want to deposit: ");
- scanf("%f",&list -> diposit_money);
- printf("Deposit successfully");
- fordelay(1000000);
- system("cls");
- menu();
- }
- else
- {
- printf("Enter your amount you want to withdraw: ");
- scanf("%f",& list ->withdraw_money);
- printf("Withdraw successfully");
- fordelay(1000000);
- system("cls");
- menu();
- }
- }
- list = list -> next;
- }
- if(test == 0)
- {
- printf("Invalid account number!\n");
- printf("Enter 1 for menu 0 for exit: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- menu();
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- printf("Enter 1 for menu 0 for exit: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- menu();
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- void new_acc()
- {
- int chose;
- data *N = (data*)malloc(sizeof(data));
- printf("\nEnter your acc_no: ");
- scanf("%d",& N -> acc_no);
- printf("Enter your name: ");
- scanf(" %[^\n]s",N -> name);
- printf("Enter your age: ");
- scanf("%d",& N -> age);
- printf("Enter your address: ");
- scanf(" %[^\n]s",N -> address);
- printf("Enter your citizenship: ");
- scanf(" %[^\n]s",N -> citizenship);
- printf("Enter your phone: ");
- scanf("%lf",& N -> phone);
- 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: ");
- scanf("%d",& N -> acc_type);
- N -> pre = NULL;
- N -> next = NULL;
- if(list == NULL)
- {
- list = N;
- head = list;
- }
- else
- {
- list -> next = N;
- N -> pre = list;
- list = list -> next;
- }
- printf("Account create successfully!\n");
- add_invalid:
- printf("Enter 1 for goto menu 0 for exit");
- scanf("%d",&chose);
- if(chose == 1)
- {
- system("cls");
- menu();
- }
- else if(chose == 0)
- {
- exit_code();
- }
- else
- {
- printf("Invalid input!");
- goto add_invalid;
- }
- }
- void edit_acc()
- {
- data *temp;
- int account_number,chose,test = 0,account_no,x;
- back:
- printf("Enter the account number whose info you want to change: ");
- scanf("%d",&account_no);
- list = head;
- while(list != NULL)
- {
- if(list -> acc_no == account_no)
- {
- test++;
- printf("Which info do you want to change?\n");
- printf("1.Address\n");
- printf("2.Phone\n");
- printf("3.Name\n");
- printf("Enter your chose: ");
- scanf("%d",&chose);
- if(chose == 1)
- {
- scanf(" %[^\n]s",list ->address);
- }
- else if(chose == 2)
- {
- scanf("%lf",&list -> phone);
- }
- else
- {
- scanf(" %[^\n]s",list ->name);
- }
- printf("Chenge saved!\n");
- }
- list = list -> next;
- }
- if(test == 0)
- {
- printf("Invalid account number!\a\n");
- printf("Enter 1 for try again 0 for manu: ");
- scanf("%d",&x);
- if(x == 1)
- {
- system("cls");
- goto back;
- }
- else if(x == 0)
- {
- system("cls");
- menu();
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- else
- {
- printf("Your account edit succuesfully");
- fordelay(100000000);
- system("cls");
- menu();
- }
- }
- void exit_code()
- {
- printf("Thank you!");
- }
- void menu()
- {
- int chose;
- system("color 3");
- printf("Enter your chose\n");
- 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");
- printf("\n\nEnter your chose: ");
- scanf("%d",&chose);
- switch(chose)
- {
- case 1:
- system("cls");
- new_acc();
- break;
- case 2:
- system("cls");
- edit_acc();
- break;
- case 3:
- system("cls");
- tranjiction();
- break;
- case 4:
- system("cls");
- exiting_acc();
- break;
- case 5:
- system("cls");
- remove_ex_acc();
- break;
- case 6:
- system("cls");
- view();
- break;
- case 7:
- system("cls");
- exit_code();
- break;
- }
- }
- void fordelay(int n)
- {
- int i,k;
- for(i=0; i<n; i++)
- {
- k = i;
- }
- }
- int main()
- {
- int n,i;
- char pass[10],password[10] = "prism";
- printf("\n\n\t\t\t\t\t\t\Welcome To Our project\n");
- back:
- printf("Enter your password: ");
- scanf(" %[^\n]s",&pass);
- system("cls");
- if(strcmp(pass,password)==0)
- {
- printf("Password matching\n Loding");
- for(i=0; i<6; i++)
- {
- fordelay(100000000);
- printf(".");
- }
- system("cls");
- menu();
- }
- else
- {
- printf("Incorrect password!\a\n");
- printf("Enter 1 to try again 0 for exit");
- scanf("%d",&n);
- if(n==1)
- {
- system("cls");
- goto back;
- }
- else
- {
- system("cls");
- exit_code();
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement