Advertisement
Mousyyyyyyy

Untitled

Feb 19th, 2020
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 12.20 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<dos.h>
  7.  
  8. //****************************************************************
  9. // CLASS USED IN PROJECT
  10. //****************************************************************
  11.  
  12. class account
  13. {
  14.     int acno, deposit, withdraw, x;
  15.     char name[50];
  16.     char type;
  17.     public:
  18.     void create_account()
  19.     {
  20.         gotoxy(12,5);cout<<"====NEW ACCOUNT ENTRY FORM====\n";
  21.         gotoxy(12,7);cout<<"Enter The account Number : ";
  22.         cin>>acno;
  23.         gotoxy(12,9);cout<<"Enter The Name of The account Holder: ";
  24.         gets(name);
  25.         gotoxy(12,11);cout<<"Enter Type of The account (C/S) : ";
  26.         cin>>type;
  27.         type=toupper(type);
  28.         gotoxy(12,13);
  29.         cout<<"Enter Initial amount>=500 for Saving & >=1000 for Current :";
  30.         cin>>deposit;
  31.         gotoxy(12,15);cout<<"Your Account Created Successfully ..";
  32.     }
  33.     void show_account()
  34.     {
  35.         gotoxy(12,4);cout<<"-------ACCOUNT STATUS-------\n";
  36.         gotoxy(12,6);cout<<"Account No.                 : "<<acno;
  37.         gotoxy(12,8);cout<<"Account Holder Name         : "<<name;
  38.         gotoxy(12,10);cout<<"Type of Account             : "<<type;
  39.         gotoxy(12,12);cout<<"Balance amount              : "<<deposit;
  40.     }
  41.     void modify_account()
  42.     {
  43.         gotoxy(12,16);cout<<"Account No.                : "<<acno;
  44.         gotoxy(12,18);cout<<"Modify Account Holder Name : ";
  45.         gets(name);
  46.         gotoxy(12,20);cout<<"Modify Type of Account     : ";cin>>type;
  47.         gotoxy(12,22);cout<<"Modify Balance amount      : ";cin>>deposit;
  48.     }
  49.     void dep(int x)
  50.     {
  51.         deposit+=x;
  52.     }
  53.     void draw(int x)
  54.     {
  55.         deposit-=x;
  56.     }
  57.     void report()
  58.     {
  59.         gotoxy(8,13);cout<<acno<<"\t\t"<<name<<"\t\t"<<type<<"\t\t"             <<deposit<<endl;
  60.     }
  61.     int retacno()
  62.     {
  63.         return acno;
  64.     }
  65.     float retdeposit()
  66.     {   return deposit;
  67.     }
  68.     char rettype()
  69.     {
  70.         return type;
  71.     }
  72. };      //class ends here
  73.  
  74. //***************************************************************
  75. //  global declaration for stream object, object
  76. //****************************************************************
  77. fstream fp;
  78. account ac;
  79.  
  80. //***************************************************************
  81. //  function for introduction
  82. //****************************************************************
  83. void welcome()
  84. {   clrscr();
  85.     int x;
  86.     /*for(x=2;x<80;x++)
  87.     {
  88.         gotoxy(x,1);
  89.         if(x%2==0)
  90.             cout<<"#";
  91.         else    cout<<" ";
  92.         delay(5);
  93.     }
  94.     for(x=2;x<25;x++)
  95.     {
  96.         gotoxy(1,x);
  97.         cout<<"#";
  98.         delay(5);
  99.     }
  100.     for(x=2;x<80;x++)
  101.     {
  102.         gotoxy(x,25);
  103.         if(x%2==0)
  104.             cout<<"#";
  105.         else    cout<<" ";
  106.         delay(5);
  107.     }
  108.     for(x=2;x<25;x++)
  109.     {
  110.         gotoxy(80,x);
  111.         cout<<"#";
  112.         delay(5);
  113.     }
  114.     delay(500);*/
  115.     gotoxy(30,12);
  116.     cout<<"LOADING....";
  117.     int u=0;
  118.     for(int i=1;i<=10;i++)
  119.     {
  120.         gotoxy(30+u,13);
  121.         delay(500);
  122.         cout<<"圹";
  123.         u=u+2;
  124.         gotoxy(52,13);
  125.         cout<<i<<"0%";
  126.     }
  127.     gotoxy(35,14);
  128.     cout<<"COMPLETE ";
  129.     delay(200);
  130.     cout<<"!";
  131.     delay(200);
  132.     cout<<"!";
  133.     delay(300);
  134.     gotoxy(50,22);
  135.     cout<<"Press Any Key To Continue";
  136.     gotoxy(0,0);
  137.     getch();
  138.     clrscr();
  139.     for(x=2;x<80;x++)
  140.     {
  141.         gotoxy(x,1);
  142.         if(x%2==0)
  143.             cout<<"#";
  144.         else    cout<<" ";
  145.         delay(5);
  146.     }
  147.     for(x=2;x<25;x++)
  148.     {
  149.         gotoxy(1,x);
  150.         cout<<"#";
  151.         delay(5);
  152.     }
  153.     for(x=2;x<80;x++)
  154.     {
  155.         gotoxy(x,25);
  156.         if(x%2==0)
  157.             cout<<"#";
  158.         else    cout<<" ";
  159.         delay(5);
  160.     }
  161.     for(x=2;x<25;x++)
  162.     {
  163.         gotoxy(80,x);
  164.         cout<<"#";
  165.         delay(5);
  166.     }
  167.     delay(500);
  168.     gotoxy(12,5);
  169.     cout<<"******************** W E L C O M E*********************";
  170.     gotoxy(19,9);
  171.     cout<<"B A N K  M A N A G E M E N T  S Y S T E M";
  172.     gotoxy(19,13);
  173.     cout<<" D E V E L O P E D  B Y : ";
  174.     gotoxy(44,13);
  175.     cout<<" VIKAS DEV TARA ";
  176.     gotoxy(42,23);
  177.     cout<<" *** PRESS ANY KEY TO CONTINUE ***";
  178.     getch();
  179. }
  180.  
  181. //****************************************************************
  182. //  function to write in file
  183. //****************************************************************
  184. void write_account()
  185. {   clrscr();
  186.     int x;
  187.     for(x=2;x<80;x++)
  188.     {
  189.         gotoxy(x,1);
  190.         if(x%2==0)
  191.             cout<<"#";
  192.         else    cout<<" ";
  193.         delay(5);
  194.     }
  195.     for(x=2;x<25;x++)
  196.     {
  197.         gotoxy(1,x);
  198.         cout<<"#";
  199.         delay(5);
  200.     }
  201.     for(x=2;x<80;x++)
  202.     {
  203.         gotoxy(x,25);
  204.         if(x%2==0)
  205.             cout<<"#";
  206.         else    cout<<" ";
  207.         delay(5);
  208.     }
  209.     for(x=2;x<25;x++)
  210.     {
  211.         gotoxy(80,x);
  212.         cout<<"#";
  213.         delay(5);
  214.     }
  215.     fp.open("account.dat",ios::out|ios::app);
  216.     ac.create_account();
  217.     fp.write((char*)&ac,sizeof(account));
  218.     fp.close();
  219. }
  220.  
  221. //****************************************************************
  222. //  function to read specific record from file
  223. //****************************************************************
  224. void display_sp()
  225. {
  226.     clrscr();
  227.     int x;
  228.     for(x=2;x<80;x++)
  229.     {
  230.         gotoxy(x,1);
  231.         if(x%2==0)
  232.             cout<<"#";
  233.         else    cout<<" ";
  234.         delay(5);
  235.     }
  236.     for(x=2;x<25;x++)
  237.     {
  238.         gotoxy(1,x);
  239.         cout<<"#";
  240.         delay(5);
  241.     }
  242.     for(x=2;x<80;x++)
  243.     {
  244.         gotoxy(x,25);
  245.         if(x%2==0)
  246.             cout<<"#";
  247.         else    cout<<" ";
  248.         delay(5);
  249.     }
  250.     for(x=2;x<25;x++)
  251.     {
  252.         gotoxy(80,x);
  253.         cout<<"#";
  254.         delay(5);
  255.     }
  256.     int n;
  257.     gotoxy(12,4);cout<<"====BALANCE DETAILS====\n";
  258.     gotoxy(12,6);cout<<"Enter the Account Number : ";
  259.     cin>>n;
  260.     int flag=0;
  261.     fp.open("account.dat",ios::in);
  262.     while(fp.read((char*)&ac,sizeof(account)))
  263.     {
  264.         if(ac.retacno()==n)
  265.         {
  266.             ac.show_account();
  267.             flag=1;
  268.         }
  269.     }
  270.     fp.close();
  271.     if(flag==0)
  272.     {
  273.         gotoxy(12,10);
  274.         cout<<"Account Number does not exist\n";
  275.     }
  276.     getch();
  277. }
  278.  
  279. //***************************************************************
  280. //  function to modify record of file
  281. //****************************************************************
  282.  
  283. void modify_account()
  284. {
  285.     clrscr();
  286.     int x;
  287.     for(x=2;x<80;x++)
  288.     {
  289.         gotoxy(x,1);
  290.         if(x%2==0)
  291.             cout<<"#";
  292.         else    cout<<" ";
  293.         delay(5);
  294.     }
  295.     for(x=2;x<25;x++)
  296.     {
  297.         gotoxy(1,x);
  298.         cout<<"#";
  299.         delay(5);
  300.     }
  301.     for(x=2;x<80;x++)
  302.     {
  303.         gotoxy(x,25);
  304.         if(x%2==0)
  305.             cout<<"#";
  306.         else    cout<<" ";
  307.         delay(5);
  308.     }
  309.     for(x=2;x<25;x++)
  310.     {
  311.         gotoxy(80,x);
  312.         cout<<"#";
  313.         delay(5);
  314.     }
  315.     int no,found=0;
  316.     gotoxy(12,5);cout<<"====MODIFY RECORD====\n";
  317.     gotoxy(12,7);cout<<"Enter the Account No. : ";
  318.     cin>>no;
  319.     fp.open("account.dat",ios::in|ios::out);
  320.     while(fp.read((char*)&ac,sizeof(account)) && found==0)
  321.     {
  322.         if(ac.retacno()==no)
  323.         {
  324.             clrscr();
  325.             for(x=2;x<80;x++)
  326.         {
  327.             gotoxy(x,1);
  328.             if(x%2==0)
  329.                 cout<<"#";
  330.             else    cout<<" ";
  331.             delay(5);
  332.         }
  333.         for(x=2;x<25;x++)
  334.         {
  335.             gotoxy(1,x);
  336.             cout<<"#";
  337.             delay(5);
  338.         }
  339.         for(x=2;x<80;x++)
  340.         {
  341.             gotoxy(x,25);
  342.             if(x%2==0)
  343.                 cout<<"#";
  344.             else    cout<<" ";
  345.             delay(5);
  346.         }
  347.         for(x=2;x<25;x++)
  348.         {
  349.             gotoxy(80,x);
  350.             cout<<"#";
  351.             delay(5);
  352.         }
  353.             ac.show_account();
  354.             gotoxy(12,14);cout<<"----Enter the New Details----\n";
  355.             ac.modify_account();
  356.             int pos=-1*sizeof(ac);
  357.             fp.seekp(pos,ios::cur);
  358.             fp.write((char*)&ac,sizeof(account));
  359.             gotoxy(12,24);cout<<"\t Record Updated\n";
  360.             found=1;
  361.         }
  362.     }
  363.     fp.close();
  364.     if(found==0)
  365.     {
  366.         gotoxy(12,10);
  367.         cout<<" Record Not Found \n";
  368.     }
  369.     getch();
  370. }
  371. //***************************************************************
  372. //  function to delete record of file
  373. //****************************************************************
  374.  
  375. void delete_account()
  376. {       clrscr();
  377.     int no, x;
  378.     for(x=2;x<80;x++)
  379.     {
  380.         gotoxy(x,1);
  381.         if(x%2==0)
  382.             cout<<"#";
  383.         else    cout<<" ";
  384.         delay(5);
  385.     }
  386.     for(x=2;x<25;x++)
  387.     {
  388.         gotoxy(1,x);
  389.         cout<<"#";
  390.         delay(5);
  391.     }
  392.     for(x=2;x<80;x++)
  393.     {
  394.         gotoxy(x,25);
  395.         if(x%2==0)
  396.             cout<<"#";
  397.         else    cout<<" ";
  398.         delay(5);
  399.     }
  400.     for(x=2;x<25;x++)
  401.     {
  402.         gotoxy(80,x);
  403.         cout<<"#";
  404.         delay(5);
  405.     }
  406.     gotoxy(12,5);cout<<"\t===Delete Record====\n";
  407.     gotoxy(12,7);cout<<"\tEnter The Account No. : ";
  408.     cin>>no;
  409.     fp.open("account.dat",ios::in|ios::out);
  410.     fstream fp2;
  411.     fp2.open("Temp.dat",ios::out);
  412.     fp.seekg(0,ios::beg);
  413.     while(fp.read((char*)&ac,sizeof(account)))
  414.     {
  415.         if(ac.retacno()!=no)
  416.         {
  417.             fp2.write((char*)&ac,sizeof(account));
  418.         }
  419.     }
  420.     fp2.close();
  421.     fp.close();
  422.     remove("account.dat");
  423.     rename("Temp.dat","account.dat");
  424.     gotoxy(12,9);cout<<"\tRecord Deleted ..\n";
  425.     getch();
  426. }
  427.  
  428. //***************************************************************
  429. //  function to display all accounts deposit list
  430. //****************************************************************
  431. void display_all()
  432. {   clrscr();
  433.     int x;
  434.     for(x=2;x<80;x++)
  435.     {
  436.         gotoxy(x,1);
  437.         if(x%2==0)
  438.             cout<<"#";
  439.         else    cout<<" ";
  440.         delay(5);
  441.     }
  442.     for(x=2;x<25;x++)
  443.     {
  444.         gotoxy(1,x);
  445.         cout<<"#";
  446.         delay(5);
  447.     }
  448.     for(x=2;x<80;x++)
  449.     {
  450.         gotoxy(x,25);
  451.         if(x%2==0)
  452.             cout<<"#";
  453.         else    cout<<" ";
  454.         delay(5);
  455.     }
  456.     for(x=2;x<25;x++)
  457.     {
  458.         gotoxy(80,x);
  459.         cout<<"#";
  460.         delay(5);
  461.     }
  462.     fp.open("account.dat",ios::in);
  463.     if(!fp)
  464.     {
  465.         gotoxy(12,5);cout<<" ERROR!!! FILE COULD NOT BE OPEN \n";
  466.         getch();
  467.         return;
  468.     }
  469.     gotoxy(15,5);cout<<"\tACCOUNT HOLDER LIST\n";
  470.     gotoxy(8,7);cout<<"=============================================================\n";
  471.     gotoxy(8,9);cout<<"A/c no.\t\tNAME\t\tType\t\tBalance\n";
  472.     gotoxy(8,11);cout<<"=============================================================\n";
  473.     while(fp.read((char *)&ac,sizeof(account)))
  474.     {
  475.         ac.report();
  476.     }
  477.     fp.close();
  478.     getch();
  479. }
  480.  
  481. //***************************************************************
  482. //  function to deposit and withdraw amounts
  483. //****************************************************************
  484. void deposit_withdraw(int option)
  485. {   clrscr();
  486.     int x;
  487.     for(x=2;x<80;x++)
  488.     {
  489.         gotoxy(x,1);
  490.         if(x%2==0)
  491.             cout<<"#";
  492.         else    cout<<" ";
  493.         delay(5);
  494.     }
  495.     for(x=2;x<25;x++)
  496.     {
  497.         gotoxy(1,x);
  498.         cout<<"#";
  499.         delay(5);
  500.     }
  501.     for(x=2;x<80;x++)
  502.     {
  503.         gotoxy(x,25);
  504.         if(x%2==0)
  505.             cout<<"#";
  506.         else    cout<<" ";
  507.         delay(5);
  508.     }
  509.     for(x=2;x<25;x++)
  510.     {
  511.         gotoxy(80,x);
  512.         cout<<"#";
  513.         delay(5);
  514.     }
  515.     int no,found=0,amt;
  516.  
  517.     gotoxy(12,4);cout<<"====ACCOUNT TRANSCATION FORM====\n";
  518.     gotoxy(12,6);cout<<"Enter The account No. : ";
  519.     cin>>no;
  520.     fp.open("account.dat",ios::in|ios::out);
  521.     while(fp.read((char*)&ac,sizeof(account)) && found==0)
  522.     {
  523.         if(ac.retacno()==no)
  524.         {
  525.             ac.show_account();
  526.             if(option==1)
  527.             {
  528.                 gotoxy(12,20);
  529.                 cout<<"Enter The amount to DEPOSIT : ";
  530.                 cin>>amt;
  531.                 ac.dep(amt);
  532.             }
  533.             if(option==2)
  534.             {
  535.                 gotoxy(12,20);
  536.                 cout<<"Enter The amount to WITHDRAW : ";
  537.                 cin>>amt;
  538.                 int bal=ac.retdeposit()-amt;
  539.                 if((bal<500 &&ac.rettype()=='S')||(bal<1000&&ac.rettype()=='C'))
  540.                     cout<<"\nInsufficient balance";
  541.                 else
  542.                     ac.draw(amt);
  543.             }
  544.             int pos=-1*sizeof(ac);
  545.             fp.seekp(pos,ios::cur);
  546.             fp.write((char*)&ac,sizeof(account));
  547.             gotoxy(12,22);cout<<"\t Record Updated \n";
  548.             found=1;
  549.         }
  550.     }
  551.     fp.close();
  552.     if(found==0)
  553.     {
  554.         gotoxy(12,10);
  555.         cout<<" Record Not Found \n";
  556.     }
  557.     getch();
  558. }
  559.  
  560. //***************************************************************
  561. //  THE MAIN FUNCTION OF PROGRAM
  562. //****************************************************************
  563. void main()
  564. {   char ch;
  565.     textcolor(YELLOW);
  566.     textbackground(BLUE);
  567.     welcome();
  568.     do
  569.     {
  570.         clrscr();
  571.         int x;
  572.         for(x=2;x<80;x++)
  573.         {
  574.             gotoxy(x,1);
  575.             if(x%2==0)
  576.                 cout<<"#";
  577.             else    cout<<" ";
  578.             delay(5);
  579.         }
  580.         for(x=2;x<25;x++)
  581.         {
  582.             gotoxy(1,x);
  583.             cout<<"#";
  584.             delay(5);
  585.         }
  586.         for(x=2;x<80;x++)
  587.         {
  588.             gotoxy(x,25);
  589.             if(x%2==0)
  590.                 cout<<"#";
  591.             else    cout<<" ";
  592.             delay(5);
  593.         }
  594.         for(x=2;x<25;x++)
  595.         {
  596.             gotoxy(80,x);
  597.             cout<<"#";
  598.             delay(5);
  599.         }
  600.         gotoxy(12,5);cout<<"MAIN MENU\n";
  601.         gotoxy(12,7);cout<<"01. NEW ACCOUNT\n";
  602.         gotoxy(12,9);cout<<"02. DEPOSIT AMOUNT\n";
  603.         gotoxy(12,11);cout<<"03. WITHDRAW AMOUNT\n";
  604.         gotoxy(12,13);cout<<"04. BALANCE ENQUIRY\n";
  605.         gotoxy(12,15);cout<<"05. ALL ACCOUNT HOLDER LIST\n";
  606.         gotoxy(12,17);cout<<"06. CLOSE AN ACCOUNT\n";
  607.         gotoxy(12,19);cout<<"07. MODIFY AN ACCOUNT\n";
  608.         gotoxy(12,21);cout<<"08. EXIT\n";
  609.         gotoxy(12,23);cout<<"Select Your Option (1-8) : ";
  610.         ch=getch();
  611.         switch(ch)
  612.         {
  613.             case '1': write_account();
  614.                   break;
  615.             case '2': deposit_withdraw(1);
  616.                   break;
  617.             case '3': deposit_withdraw(2);
  618.                   break;
  619.             case '4': display_sp();
  620.                   break;
  621.             case '5': display_all();
  622.                   break;
  623.             case '6': delete_account();
  624.                   break;
  625.             case '7': modify_account();
  626.                   break;
  627.             case '8': exit(0);
  628.         }
  629.     }while(ch!='8');
  630. }
  631.  
  632. //***************************************************************
  633. //      END OF PROJECT
  634. //***************************************************************
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement