Advertisement
Guest User

SYSTEM

a guest
Sep 24th, 2017
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 8.58 KB | None | 0 0
  1. #include<fstream.h>
  2. #include<conio.h>
  3. #include<stdio.h>
  4. #include<process.h>
  5. #include<ctype.h>
  6. #include<string.h>
  7.  
  8. //***************************************************************************
  9. //                           CLASS USE
  10. //***************************************************************************
  11.  
  12. class account
  13. {
  14.     int acno,deposit,withdraw,toupper;
  15.     char name[50];
  16.     char type;
  17.     public:
  18.     void create_account()
  19.     {      int no;
  20.         cout<<"\n\n====NEW ACCOUNT ENTRY FORM====\n\n";
  21.         cout<<"\nENTER THE ACCOUNT NUMBER:";
  22.         cin>>no;
  23.         cout<<"\nENTER THE NAME OF THE ACCOUNT HOLDER:";
  24.         gets(name);
  25.         cout<<"\nENTER TYPE OF THE ACCOUNT (C/S) :";
  26.         cin>>type;
  27.  
  28.  
  29.  
  30.         cout<<"\nENTER INITIAL AMOUNT\n>=500 for Saving >=1000 for current :";
  31.         cin>>deposit;
  32.         cout<<"\n\n\nYour Account Created Successfully ..";
  33.     }
  34.     void show_account()
  35.     {
  36.         cout<<"\n\n----ACCOUNT STATUS----\n";
  37.         cout<<"\nAccount No. : "<<acno;
  38.         cout<<"\nAccount Holder Name:"<<name;
  39.         cout<<"\nType of Account:"<<type;
  40.         cout<<"\nBalance amount:"<<deposit;
  41.     }
  42.     void modify_account()
  43.     {       char type;
  44.         int deposit;
  45.         cout<<"\nAccount No. :"<<acno;
  46.         cout<<"\nModify Account Holder Name:";
  47.         gets(name);
  48.         cout<<"\nModify Type Of Account:";cin>>type;
  49.         cout<<"\nModify Balance amount:";cin>>deposit;
  50.     }
  51.     void dep(int x)
  52.     {
  53.         deposit+= x;
  54.     }
  55.     void draw(int x)
  56.     {
  57.         deposit-= x;
  58.     }
  59.     void report()
  60.     {
  61.         cout<<acno<<"\t"<<name<<"\t\t<<type<<"<<deposit<<endl;
  62.        }
  63.  
  64.      {
  65.         return acno;
  66.     }
  67.  
  68.  
  69.     float retdeposit()
  70.     {
  71.         return deposit;
  72.     }
  73.     char rettype()
  74.     {
  75.     }
  76.     };          //class ends here
  77. //***************************************************************************
  78. //  global decleration for stream object, object
  79. //***************************************************************************
  80.  
  81. fstream fp;
  82. account ac;
  83.  
  84. //***************************************************************************
  85. //      function to write in file
  86. //***************************************************************************
  87.  
  88. void write_account()
  89. {
  90.     fp.open("account.dat",ios::in||ios::out);
  91.     ac.create_account();
  92.     fp.write((char*)&ac,sizeof(account));
  93.     fp.close();
  94. }
  95. //***************************************************************************
  96. //  function to read specific record in file
  97. //***************************************************************************
  98.  
  99. void display_ap()
  100. {
  101.     int n;
  102.     cout<<"\n\n************BALANCE DETAILS****************";
  103.     cout<<"\n\nEnter The Account Number: ";
  104.     cin>>n;
  105.     int flag=0;
  106.     fp.open("account.dat",ios::in||ios::out);
  107.     while(fp.read((char*)&ac,sizeof(account)))
  108.     {
  109.         if(ac.retacno()==n)
  110.         {
  111.             ac.show_account();
  112.             flag=1;
  113.         }
  114.     }
  115.     {
  116.     fp.close();
  117.     if(flag==0)
  118.         cout<<"\n\nACOOUNT NUMBER DOES NOT EXIST";
  119.     getch();
  120. }
  121. //**************************************************************************
  122. //      function to modify record of file
  123. //***************************************************************************
  124. void modify_account()
  125. {
  126.     int no, found=0;
  127.     cout<<"\n\n************MODIFY RECORD******************";
  128.     cout<<"\n\nENTER THE ACOOUNT NUMBER: ";
  129.     cin>>no;
  130.     fp.open("account.dat",ios::in|ios::out);
  131.     while(fp.read((char*)&ac,sizeof(account)) && found==0;
  132.     {
  133.         if(ac.retacno()==no)
  134.         {
  135.             ac.show_account();
  136.             cout<<"\n\n-----ENTER THE NEW DETAILS-----\N";
  137.             ac.modify_account();
  138.             int pos=1*sizeof(ac);
  139.             fp.seekp(pos,ios::cur);
  140.             fp.write((char*)&ac,sizeof(account));
  141.             cout<<"\n\n\t RECORD UPDATED";
  142.             found=1;
  143.  
  144.         }
  145.     }
  146.     fp.close();
  147.     if(found==0)
  148.         cout<<"\n\nRecord Not Found";
  149.     getch();
  150. }
  151. //***************************************************************************
  152. //         function to delete record of file
  153. //***************************************************************************
  154. void delete_account()
  155. {
  156.     int no;
  157.     cout<<"\n\n**********DELETE RECORD**********";
  158.     cout<<"\n\nENTER THE ACOOUNT NO.:";
  159.     cin>>no;
  160.     fp.open("account.dat",ios::in||ios::out);
  161.     fstream fp2;
  162.     fp2.("Temp.dat",ios::out);
  163.     fp.seekp(0,ios::bug);
  164.     while(fp.read((char*)&ac,sizeof()))
  165.     {
  166.         if(ac.retacno() t=no)
  167.         {
  168.             fp2.write((char*)&ac,sizeof(account));
  169.         }
  170.     }
  171.     close();
  172.     fp.close();
  173.     remove("account.dat");
  174.     rename("Temp.dat","account.dat");
  175.     cout<<"\n\nt RECORD DELETEC..";
  176.     getch();
  177. }
  178. //***************************************************************************
  179. //  function to display all accounts deposit list
  180. //***************************************************************************
  181.  
  182. void display_all()
  183. {
  184.     fp.open("acoount.dat",ios::in);
  185.     if(!fp)
  186.     {
  187.         cout<<"ERROR!!! FILE COULD NOT BE OPEN";
  188.         getch();
  189.         return
  190.  
  191.     }
  192.     cout<<"\n\n ACCOUNT HOLDER LIST\n\n";
  193.     cout<<"=========================================================\n";
  194.     cout<<"A/c no.\tNAME\t\tTYPE\t\tBALANCE\n";
  195.     cout<<"=========================================================\n";
  196.     while(fp.read((char*)&ac,sizeof(account)))
  197.     {
  198.         ac.report();
  199.     }
  200.     fp.close();
  201.     getch();
  202. //***************************************************************************
  203. //  function to deposit and withdraw ammounts
  204. //***************************************************************************
  205. void deposit_withdraw(int option)
  206. {
  207.     int no,found=0,amt;
  208.     cout<<"\n\n======ACCOUNT TRANSACTION FOR======";
  209.     cout<<"\n\n ENTER THE ACCOUNT NO. :";
  210.     cin>>no;
  211.     fp.open("account.dat",ios::in|ios::out);
  212.     while(fp.read((char*)&ac,sizeof(account)) && found==0;
  213.     {
  214.         if(ac.retacno()==no)
  215.             ac.show_account();
  216.             if(option==1)
  217.              {
  218.                 cout<<"\n\n ENTER THE AMOUNT TO DEPOSIT:";
  219.                 cin>>amt;
  220.                 ac.dep();
  221.              }
  222.              if(option=2)
  223.              {
  224.                 cout<<"\n\n ENTER THE AMOUNT TO WITHDRAW:";
  225.                 cin>>amt;
  226.                 int bal=ac.retdeposit()-amt;
  227.                 if(bal<500 &&ac.rettype()=='S') || (bal<1500 && ac.rettype()=='C'))
  228.                     cout<<"\n INUSUFICIENCE BALANACE";
  229.                 else
  230.                     ac.draw(amt);
  231.                 }
  232.                 int pos=-1*sizeof(ac);
  233.                 fp.seekp(pos,ios::cur);
  234.                 fp.write((char*)&ac,sizeof(account));
  235.                 cout<<"\n\nt RECORD UPDATED";
  236.                 found=1;
  237.              }
  238.         }
  239.         {
  240.         fp.close();
  241.         if(found==0)
  242.             cout<<"\n\n RECORD NOT FOUND";
  243.         getch();
  244.     }
  245. //***************************************************************************
  246. //      INTRODUCTION FUNCTION
  247. //***************************************************************************
  248.  
  249. void intro()
  250. {
  251.     clrscr();
  252.     textbackground(BLACK);
  253.     gotoxy(25,7)
  254.     cout<<"===========================================================";
  255.     gotoxy(15,11);
  256.     cout<<"BANK";
  257.     gotoxy(23,14)
  258.     cout<<"MANAGEMENT";
  259.     gotoxy(25,17)
  260.     cout<<"SYSTEM";
  261.     gotoxy(25,21);
  262.     cout<<"===========================================================";
  263.     gotoxy(25,24);
  264.     cout<<"MADE BY : ADMINISTRATOR";
  265.     gotoxy(25,24);
  266.     cout<<"SCHOOL : AICS";
  267.     getch();
  268. }
  269. //***************************************************************************
  270. //      THE MAINFUNCTION OF PROGRAM
  271. //***************************************************************************
  272. void main()
  273. {
  274.     char ch;
  275.     char pass,ox;
  276.     char password[100],passv[100],userid[100];
  277.  
  278.     INT I= 0,counter =0;
  279.     do
  280.     {
  281.     clrscr();
  282.     gotoxy(32,15);
  283.     cout<<"Enter Username:";
  284.     gotoxy(32,18)
  285.     cout<<"Enter Passwod:";
  286.     cout<<" ";
  287.  
  288.     while(1)
  289.     {
  290.         pass=getch();
  291.  
  292.         if(pass==11)
  293.         {
  294.         break;
  295.         }
  296.  
  297.         if (pass==8)
  298.         {
  299.         putch("\b");
  300.         putch(NULL);
  301.         putch("\b");
  302.         --1;
  303.         continue;
  304.         }
  305.         if (pass<='7' &&pass >='1'|| pass>='a' && pass<='a' || pass>='A' && pass<='A')
  306.         {
  307.         passv[i++]=pass;
  308.         cout<<"*";
  309.         else
  310.         continue;
  311.     }
  312.     cout<<"\n\n";
  313.     passv='\n';
  314.     if((strcmp)(Userid, "admin")== 0 && strcmp(passv,"admin") ==0 )
  315.     {
  316.     textcolor(YELLOW);
  317.     gotoxy(32,22);
  318.     cout<<"Login Success";
  319.     gotoxy(32,25);
  320.     cout<<"Press any ket to continue";
  321.     getch();
  322.     goto A;
  323.     }
  324.  
  325.     else
  326.     {
  327.     gotoxy(32,21);
  328.     cout<<"Invalid username or password";
  329.     i=0;
  330.     counter++;
  331.     if(counter ==3)
  332.     {
  333.     clrscr();
  334.     gotoxy(32,22);
  335.     cout<<"Try again later";
  336.     getch();
  337.  
  338.     }
  339.     else
  340.     {
  341.     gotoxy(32,23)
  342.     cout<<"Try again[y/n]";
  343.     cin>>ex;
  344.     }
  345.     }
  346.     }
  347.     while(ex=='y' || ex=='Y');
  348.     exit(0);
  349.  
  350.     A:
  351.     intro();
  352.     do
  353.     {
  354.     gotoxy(52,3);
  355.     cout<<"[D] Delete";
  356.     gotoxy(63,3);
  357.     cout<<"[Q]QUIT";
  358.     gotoxy(5,3);
  359.     cout<<"Option";
  360. }
  361.     void Inv::intToStr(){
  362.     int i=0;
  363.     if(Itemno>99){
  364.         Itemno-= 100; i++;
  365.         } CItemno[0]=i + '0'; 1=0;
  366.     while(Itemno>9){
  367.         Itemno-= 10; i++;
  368.         } CItemno[1]=i + '0'; 1=0;
  369.     CItemno[2]=Itemno+'0'; i=0;
  370.     if(Quantity>99){
  371.         Quantity-= 100; i++;
  372.     }CQuantity[0]=i+'0'; i=0;
  373.     while(Quantity>9){
  374.         Quantity-=10; i++;
  375.     }CQuantity[1]=i+'0';
  376.     CQuantity[2]=Quantity+'0'; i=0;
  377.     if(Price>999){ Price-=1000; i++; }CPrice[0]=i+'0'; i=0;
  378.     while(Price>99){ Price-=100;i++;}CPrice[1]=i+'0'; i=0;
  379.     while(Price>9){ Price-=10;i++;}CPrice[2]=i+'0';
  380.     {
  381.     CPrice[3]=Price+'0';i=0;
  382.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement