Radoan_Ahmed

Untitled

Dec 5th, 2019
174
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.82 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3. #include<windows.h>
  4. int i,j;
  5. int main_exit;
  6. void menu();
  7. struct date{
  8.     int month,day,year;
  9.  
  10.     };
  11. struct {
  12.  
  13.     char name[60];
  14.     int acc_no,age;
  15.     char address[60];
  16.     char citizenship[15];
  17.     double phone;
  18.     char acc_type[10];
  19.     float amt;
  20.     struct date dob;
  21.     struct date deposit;
  22.     struct date withdraw;
  23.  
  24.     }add,upd,check,rem,transaction;
  25.  
  26. float interest(float t,float amount,int rate)
  27. {
  28.     float SI;
  29.     SI=(rate*t*amount)/100.0;
  30.     return (SI);
  31.  
  32. }
  33. void fordelay(int j)
  34. {   int i,k;
  35.     for(i=0;i<j;i++)
  36.          k=i;
  37. }
  38.  
  39. void new_acc()
  40.  
  41. {
  42.     int choice;
  43.     FILE *ptr;
  44.  
  45.     ptr=fopen("record.dat","a+");
  46.     account_no:
  47.     system("cls");
  48.     printf("\t\t\t\xB2\xB2\xB2\ ADD RECORD  \xB2\xB2\xB2\xB2");
  49.     printf("\n\n\nEnter today's date(mm/dd/yyyy):");
  50.     scanf("%d/%d/%d",&add.deposit.month,&add.deposit.day,&add.deposit.year);
  51.     printf("\nEnter the account number:");
  52.     scanf("%d",&check.acc_no);
  53.     while(fscanf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",&add.acc_no,add.name,&add.dob.month,&add.dob.day,&add.dob.year,&add.age,add.address,add.citizenship,&add.phone,add.acc_type,&add.amt,&add.deposit.month,&add.deposit.day,&add.deposit.year)!=EOF)
  54.     {
  55.         if (check.acc_no==add.acc_no)
  56.             {printf("Account no. already in use!");
  57.             fordelay(1000000000);
  58.                 goto account_no;
  59.  
  60.             }
  61.     }
  62.     add.acc_no=check.acc_no;
  63.         printf("\nEnter the name:");
  64.     scanf("%s",add.name);
  65.     printf("\nEnter the date of birth(mm/dd/yyyy):");
  66.     scanf("%d/%d/%d",&add.dob.month,&add.dob.day,&add.dob.year);
  67.     printf("\nEnter the age:");
  68.     scanf("%d",&add.age);
  69.     printf("\nEnter the address:");
  70.     scanf("%s",add.address);
  71.     printf("\nEnter the citizenship number:");
  72.     scanf("%s",add.citizenship);
  73.     printf("\nEnter the phone number: ");
  74.     scanf("%lf",&add.phone);
  75.     printf("\nEnter the amount to deposit:$");
  76.     scanf("%f",&add.amt);
  77.     printf("\nType of account:\n\t#Saving\n\t#Current\n\t#Fixed1(for 1 year)\n\t#Fixed2(for 2 years)\n\t#Fixed3(for 3 years)\n\n\tEnter your choice:");
  78.     scanf("%s",add.acc_type);
  79.  
  80.         fprintf(ptr,"%d %s %d/%d/%d %d %s %s %lf %s %f %d/%d/%d\n",add.acc_no,add.name,add.dob.month,add.dob.day,add.dob.year,add.age,add.address,add.citizenship,add.phone,add.acc_type,add.amt,add.deposit.month,add.deposit.day,add.deposit.year);
  81.  
  82.  
  83.     fclose(ptr);
  84.     printf("\nAccount created successfully!");
  85.     add_invalid:
  86.     printf("\n\n\n\t\tEnter 1 to go to the main menu and 0 to exit:");
  87.     scanf("%d",&main_exit);
  88.     system("cls");
  89.     if (main_exit==1)
  90.         menu();
  91.     else if(main_exit==0)
  92.             close();
  93.     else
  94.         {
  95.             printf("\nInvalid!\a");
  96.             goto add_invalid;
  97.         }
  98. }
Advertisement
Add Comment
Please, Sign In to add comment