Advertisement
sohom15

Railways

Oct 10th, 2014
290
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 19.74 KB | None | 0 0
  1. #include<iostream>
  2. #include<fstream>
  3. #include<string.h>
  4. #include<stdio.h>
  5. #include<time.h>
  6. #include<iomanip>
  7. #include<process.h>
  8.  
  9. using namespace std;
  10.  
  11. char f[2]="f";
  12. char s[2]="s";
  13. int addr,ad,flag=1,f1,d,m,i,amt;
  14. float tamt;
  15.  
  16.  
  17. /*class login
  18. {
  19. public:
  20.     char id[2];
  21.     char pass[30];
  22.     char *password;
  23.     void getid();
  24.     void displayid();
  25. };
  26. void login::getid()
  27. {
  28.         cout<<"Enter ID";
  29.         gets(id);
  30.         password=getpass("enter password:");
  31.         strcpy(pass,password);
  32. }
  33. void login::displayid()
  34. {
  35.         cout<<"User ID information:"<<endl<<endl;
  36.         cout<<"ID";
  37.         puts(id);
  38.         cout<<endl;
  39.         cout<<"Password:";
  40.         puts(pass);
  41. }*/
  42. class detail
  43. {
  44. public:
  45.     int tno;
  46.     char tname[24],bp[20],dest[20],c1,c1fare,c2,c2fare;
  47.     int d,m,y;
  48.     void getdetail();
  49.     void displaydetail();
  50. };
  51. void detail::displaydetail()
  52. {
  53.         cout<<"............................................";
  54.         cout<<".............................................................";
  55.         cout<<"Tr No| Tr Name | Start | Destin|";
  56.         cout<<"FC se | SC se| Fr FC| Fr SC| Date of jo";
  57.         cout<<"\n..........................";
  58.         cout<<".........................................\n";
  59.         cout<<tno<<" "<<tname<<" "<<bp<<" "<<dest<<" "<<c1<<" "<<c2;
  60.         cout<<"  "<<c1fare<<" "<<c2fare<<" "<<d<<"/"<<m<<"/"<<y<<endl;
  61.         cout<<"....................................................";
  62.         cout<<"...................................................................";
  63. }
  64. void detail::getdetail()
  65. {
  66.  
  67.         cout<<"Enter the detail as follows"<<endl;
  68.         cout<<"train number";
  69.         cin>>tno;
  70.         cout<<"Train name";
  71.         gets(tname);
  72.         cout<<"boarding point";
  73.         gets(bp);
  74.         cout<<"Destination point";
  75.         gets(dest);
  76.         cout<<"no of seats in first class"<<endl;
  77.         cout<<"And fare pre ticket:";
  78.         cin>>c1>>c1fare;
  79.         cout<<"number of seats of second class"<<endl<<"and fare per ticket";
  80.         cin>>c2>>c2fare;
  81.         cout<<"Date of travel(in dd/mm/yy):";
  82.         cin>>d>>m>>y;
  83. }
  84. class reser : public detail
  85. {
  86. public:
  87.     int pnr,tno;
  88.     char tname[30];
  89.     char bp[20],dest[20];
  90.     char pname[100][100];
  91.     int age[20];
  92.     char clas[100];
  93.     int nosr,i,d,m,y,con;
  94.     float amc;
  95.     void getresdet();
  96.     cout<<"Enter class";
  97.     cout<<endl<<"f for first class"<<endl<<"s for second class";
  98.     gets(clas);
  99.     cout<<"date of travel";
  100.     cin>>d>>m>>y;
  101.     cout<<"\n\nenter concessions from below\n";
  102.     cout<<"1.Military \n2.Senior citizen\n";
  103.     cout<<"3.Children below 5 years\n4.none\n";
  104.     cout<<"Enter your choice:";
  105.     cin>>con;
  106. };
  107. void reser::getresdet()
  108. {
  109.  
  110.         cout<<"Enter the details as follows"<<endl;
  111.         cout<<"train number :";
  112.         cin>>tno;
  113.         cout<<"Train name:";
  114.         gets(tname);
  115.         cout<<"Boarding point";
  116.         gets(bp);
  117.         cout<<"detination point";
  118.         gets(dest);
  119.         cout<<"No of seats required:";
  120.         cin>>nosr;
  121.         for(i=0;i<nosr;i++)
  122.         {
  123.             cout<<"Passenger("<<i+1<<")name:";
  124.             gets(pname[i]);
  125.             cout<<"Passenger("<<i+1<<")age:";
  126.             cin>>age[i];
  127.         }
  128. }
  129. void displayresdet()
  130. {
  131.     cout<<endl;
  132.     cout<<"...........................................................\n";
  133.     cout<<"                 RESERVATION STATUS         \n";
  134.     cout<<"...........................................................\n";
  135.     cout<<"PNR number                                    :"<<pnr<<endl;
  136.     cout<<"Train number                                  :"<<tno<<endl;
  137.     cout<<"Train name                                    :"; puts(tname);
  138.     cout<<"Boarding point                                :"; puts(bp);
  139.     cout<<"Destination point                             :"; puts(dest);
  140.     cout<<"number of seats reserved :"<<nosr<<endl;
  141.     for(i=0;i<nosr;i++)
  142.     {
  143.         cout<<"Passenger"<<i+1<<"name:";
  144.         puts(pname[i]);
  145.         cout<<"passenger"<<i+1<<"age";
  146.     }
  147.     cout<<"your class"; puts(clas);
  148.     cout<<"dat of resevation:"<<d<<"/"<<m<<"/"<<y;
  149.     cout<<endl<<"your concession category:"<<con;
  150.     cout<<"\n you must pay:"<<amc<<endl;
  151.     cout<<"..................................................................\n";
  152.     cout<<"                 END OF RESERVATION  DETAILS OF PASSENGER \n";
  153.     cout<<"..................................................................\n";
  154. }
  155. class canc:public detail
  156. {
  157. public:
  158.     int pnr,tno;
  159.     char tname[200],bp[20],dest[30],pname[10][100];
  160.     int age[100];
  161.     int i;
  162.     char cins[100];
  163.     char clas[100];
  164.     int nasc;
  165.     int d,m,y;
  166.     float amc;
  167.     void getcancdet()
  168.     {
  169.         cout<<"\n\n Enter the details as follows \n";
  170.         cout<<"\nPNR number:";
  171.         cin>>pnr;
  172.         cout<<"\n Date of cancellation:";
  173.         cin>>d>>m>>y;
  174.     }
  175.     void canc::displaycancdet()
  176.     {
  177.         cout<<"..........................................\n";
  178.         cout<<"  DISPLAY OF CANCELLTION\N";
  179.         cout<<".........................................\N";
  180.         cout<<"pnr number:"<<pnr<<endl;
  181.         cout<<"Train number :"<<tno<<endl;
  182.         cout<<"train name:"; puts(tname);
  183.         cout<<"Boarding point:"; puts(bp);
  184.         cout<<"Destination point: "; puts(dest);
  185.         cout<<"your class:";puts(clas);
  186.         cout<<"No of seats has been cancelled: "<<nasc<<endl;
  187.         for(i=0;i<nasc;i++)
  188.         {
  189.             cout<<"Passenger name  :";
  190.             puts(pname[i]);
  191.             cout<<"Passenger age   :"<<age[i]<<endl;
  192.         }
  193.         cout<<"Date of cancellation:"<<d<<"/"<<m<<"/"<<y;
  194.         cout<<"you can collect   :Rs."<<amc<<endl;
  195.         cout<<".........................................\n";
  196.         cout<<"          END OF CANCELLATION                \n";
  197.         cout<<".........................................\n";
  198.     }
  199.     void manage();
  200.     void can();
  201.     void user();
  202.     void database();
  203.     void reser();
  204.     void displaypassdate();
  205.     void cancel();
  206.     void enquiry();
  207. };
  208. int main()
  209. {
  210.     int ch;
  211.     canc object;
  212.     do
  213.     {
  214.         cout<<".............................................................\n";
  215.         cout<<"      WELCOME TO ONLINE RESERVATION SYSTEM \n";
  216.         cout<<"............................................................\n";
  217.         cout<<"\n\n.................................................\n";
  218.         cout<<"MAIN MENU                               \n";
  219.         cout<<".......................................................\n";
  220.         cout<<"\n\\n Admission \n\n1.Admin mode \n 2.User mode\n\n3.Exit\n";
  221.         cout<<"Enter your choice \n";
  222.         cin>>ch;
  223.         cout<<endl;
  224.         switch(ch)
  225.         {
  226.             case 1:
  227.                 object.database();
  228.                 break;
  229.             case 2:
  230.                 object.user();
  231.                 break;
  232.             case 3:
  233.                 exit(0);
  234.         }
  235.     }while(ch<=3);
  236.  
  237. }
  238. void database()
  239. {
  240.     char *password;
  241.     char *pass="abc";
  242.     password=getpass();
  243.     detail a;
  244.     int ch;
  245.     char c;
  246.     if(strcmp(pass,password)!=0)
  247.     {
  248.         char c;
  249.         do
  250.         {
  251.  
  252.             cout<<"\n............................................................\n";
  253.             cout<<"\n                               Adminsita                          \n";
  254.             cout<<".......................................";
  255.             cout<<"\n\n1.Add details \n";
  256.             cout<<"\n2.Display details\n\n3.user management\n";
  257.             cout<<"\n4.Display passenger details \n\n5. return to main menu \n";
  258.             cout<<"\n Enter your choice:";
  259.             cin>>ch;
  260.             cout<<endl;
  261.             switch(ch)
  262.             {
  263.             case 1:
  264.                 f.open("t.txt",ios::in|ios::out|ios::binary|ios::app);
  265.                 do
  266.                 {
  267.                     a.getdetail();
  268.                     f.write((char*)&a,sizeof(a));
  269.                     cout<<"\n\nDo you want to add one more record?\n";
  270.                     cout<<"y-Yes\n n-No\n";
  271.                     cout<<"Your answer:";
  272.                     cin>>c;
  273.                 }
  274.                 while(c=='y')
  275.                 f.close();
  276.                 break;
  277.             case 2:
  278.                 f.open("t.txt",ios::in||ios:out||ios::binary||ios::app);
  279.                 f.seekg(0);
  280.                 while(f.read((char*)&a.sizeof(a)))
  281.                 {
  282.                     a.displaydetail();
  283.                 }
  284.  
  285.                 f.close();
  286.                 break;
  287.             case 3:
  288.                 manage();
  289.                 break;
  290.             case 4:
  291.                 displaypassdetail();
  292.                 break;
  293.             default:
  294.                 cout<<"INVALID CHOICE";
  295.             }
  296.         }while(ch<=4);
  297.         f.close();
  298.     }
  299. }
  300.  
  301. void reserve()
  302. {
  303.     int ch;
  304.     do
  305.     {
  306.         cout<<"1.reserve\n\n.2return to main menu";
  307.         cout<<"Enter your choice:";
  308.         cin>>ch;
  309.         cout<<endl;
  310.         switch(ch);
  311.         {
  312.         case 1;
  313.             res();
  314.             break;
  315.         case 2:
  316.         default:
  317.             cout<<"INVALID CHOICE";
  318.         }
  319.     }
  320.     while(ch==1)
  321. }
  322. void res()
  323. {
  324.     detail a;
  325.     reser b;
  326.     fstream f1,f2;
  327.     time_t t;
  328.     f1.open("t.txt",ios::in|ios::out|ios::binary);
  329.     f2.open("p.txt",ios::in|ios::out|ios::binary|ios::app);
  330.     int ch;
  331.     b.getresdet();
  332.     while(f1.read((char*)&a.sizeof(a)))
  333.     {
  334.         if(a.tno==b.tno)
  335.         {
  336.             if(strcmp(b.clas,f)==0)
  337.             {
  338.                 if(a.c1>=b.nosr)
  339.                 {
  340.                     amt=a.c1fare;
  341.                     addrf1.tellg();
  342.                     ad=sizeof(a.c1);
  343.                     f1.seekp(addr-(7*ad));
  344.                     a.c1=a.c1-b.nosr;
  345.                     f1.write(char*)&a.c1,sizeof(a.c1));
  346.                     if(b.con==1)
  347.                     {
  348.                         cout<<"\nconcession category:MILITARY PERSONNEL\n";
  349.                         b.amc=b.nosr*((amt*50)/100);
  350.                     }
  351.                     else if(b.con==2)
  352.                     {
  353.                         cout<<"\nconcession category:SENIOR CITIZEN\n";
  354.                         b.amc=b.nosr*((amt*60)/100);
  355.                     }
  356.                     else if(b.con==3)
  357.                     {
  358.                         cout<<"\nconcession category:CHILDREN BELOW FIVE\n";
  359.                         b.amc=0.0;
  360.                     }
  361.                     else if(b.con==4)
  362.                     {
  363.                         cout<<"\nyou can not get any concession \n";
  364.                         b.amc=b.nosr*amt;
  365.                     }
  366.                     s.rand(unsigned)time(&t));
  367.                     b.pnr=rand();
  368.                     f2.write((*char)&b.sizef(b));
  369.                     b.displayresdet();
  370.                     cout<<"......................................................................\n";
  371.                     cout<<"        YOUR TICKET HAS BEEN RESERVED    \n";
  372.                     cout<<".......................................................................\n";
  373.                 }
  374.                 else
  375.                 {
  376.                     cout<<".......................................................................\n";
  377.                     cout<<"           SORRY REQUESTED SEATS ARE NOT AVAILABLE                     \n";
  378.                     cout<<"........................................................................\n";
  379.                 }
  380.             }
  381.             else if(strcmp(b.clas.s)==0)
  382.             {
  383.                 if(a.c2>=b.nosr)
  384.                 {
  385.                     amt=a.c2fare;
  386.                     addr=f1.tellg();
  387.                     ad=sizeof(a.c2);
  388.                     f1.seekp(addr-95*ad0);
  389.                     a.c2=a.c2-b.nosr;
  390.                     f1.write((char*)&a.c2,sizeof(a.c2));
  391.                     if(b.con==1)
  392.                     {
  393.                         cout<<"\nconcession category:MILITARY PERSONNEL\N";
  394.                         b.amc=b.nosr*((amt*50)/100);
  395.                     }
  396.                     else if(b.con==2)
  397.                     {
  398.                         cout<<"\nconcession category:SENIOR CITIZEN\n";
  399.                         b.amc=b.nosr*((amt*60)/100);
  400.                     }
  401.                     else if(b.con==3)
  402.                     {
  403.                         cout<<"\nconcession category:CHILDREN BELOW FIVE\N";
  404.                         b.amc=0.0;
  405.                     }
  406.                     else if(b.con==4)
  407.                     {
  408.                         cout<<"\nyou can get no concession\n";
  409.                         b.amc=b.nosr*amt;
  410.                     }
  411.                     f2.write((char*)&b.sizeof(b));
  412.                     b.displayresdet();
  413.                     cout<<"........................................................\n";
  414.                     cout<<"     YOUR TICKET HAS BEEN RESERVED     \n";
  415.                     cout<<".........................................................\n";
  416.                 }
  417.                 else
  418.                 {
  419.  
  420.                     cout<<"........................................................\n";
  421.                     cout<<"                  SORRY REQUIRED SEATS ARE NOT AVAILABLE\n";
  422.                 }
  423.             }
  424.  
  425.             goto h;
  426.         }
  427.         else
  428.         {
  429.             flag=0;
  430.         }
  431.     }
  432.     if(flag==0)
  433.     {
  434.         cout<<"..........................................\n";
  435.         cout<<"wrong train number \n";
  436.         cout<<"..........................................\n";
  437.         cout<<"Enter train number from database\n";
  438.         cout<<".......................\n";
  439.     }
  440.     f1.close();
  441.     f2.closw();
  442.     h:
  443. }
  444. void displaypassdetail()
  445. {
  446.     fstream f;
  447.     reser b;
  448.     f.open("p.txt",ios::in|ios::out|ios::binary);
  449.     f.seekg(0);
  450.     while(f.reas((char*)&b.sizeof(b))
  451.     {
  452.         b.displayresdet();
  453.     }
  454.     f.close();
  455.  
  456. }
  457. void enquiry()
  458. {
  459.     fstream f;
  460.     f.open("t.txt",ios::in|ios::out|ios::binary);
  461.     detail a;
  462.     while(f.read((char*)&a.sizeof(a)))
  463.     {
  464.         a.displaydetail();
  465.     }
  466.  
  467. }
  468. void cancel()
  469. {
  470.     detail a;
  471.     reser b;
  472.     conc a;
  473.     fstream f1,f2,f3;
  474.     f1.open("t.txt",ios::in||ios::out||ios::binary);
  475.     f2.open("p.txt",ios::in||ios||out||ios::binary);
  476.     f3.open("cn.txt",ios::in||ios||out||ios::binary);
  477.  
  478.     cout<<".............................................................\n";
  479.     cout<<"     CANCELLATION MENU   \n";
  480.     cout<<".............................................................\n";
  481.     c.getcancdet();
  482.     while(f2.read((char*)&b.sizeof(b)))
  483.     {
  484.         if(b.pnr==c.pnr)
  485.         {
  486.             c.tnc=b.tnc;
  487.             strcpy(c.tname,b.tname);
  488.             strcpy(c.bp,b.bp);
  489.             strcpy(c.dest,b.dest);c.nasc=b.nasr;
  490.             for(int j=0;j<.nasc;j++)
  491.             {
  492.                 strcpy(c.pname[j],b.pname[j]);
  493.                 c.age[j]=b.age[j];
  494.             }
  495.             strcpy(c.clas,b.clas);
  496.             if(strcmp(c.clas.f)==0)
  497.             {
  498.                 while(f1.read((char*)&a.sizeof(a)))
  499.                 {
  500.                     if(a.tno=c.tno)
  501.                     {
  502.                         a.c1=a.c1+c.nasc;
  503.                         d=a.d;
  504.                         m=a.m;
  505.                         addr=f1.tellg();
  506.                         ad=sizeof(a.c1);
  507.                         f1.seekp(addr-(7*ad));
  508.                         f1.write((char*)&a.c1,sizeof(a.c1));
  509.                         t.amt=b.amc;
  510.                         if(c.d==d)&&(c.m==m))
  511.                         {
  512.                             cout<<"you are cancelling at the date of departure"<<endl;
  513.                             c.amr=t.amt-((t.amt*60)/100);
  514.                         }
  515.                         else if(c.m==m)&&(c.d<d))
  516.                         {
  517.                             cout<<"you are acnelling in the date of departure"<<endl;
  518.                             c.amr=t.amt-((t.amt*50)/100);
  519.                         }
  520.                         else if(m>c.m)
  521.                         {
  522.                             cout<<"your are cancelling"<<m-c.m<<"month before the date of depertaure"<<Endl;
  523.                             c.amr=t.amt-((t.amt*20)/100);
  524.                         }
  525.                         else
  526.                         {
  527.                             cout<<"you are cancelling after the departure"<<endl;
  528.                             cout<<"your request cannot be completed"<<endl;
  529.                         }
  530.                         fstream fp2;
  531.                         fp2.open("temp.dat",ios::out);
  532.                         f2.seekg(o,ios::beg);
  533.                         while(f2.read((char*)&b.sizeof(b)))
  534.                         {
  535.                             if(b.pnr!=c.pnr)
  536.                             {
  537.                                 fp2.write((char*)&b.sizeof(b));
  538.                             }
  539.                         }
  540.                         fp2.close();
  541.                         remove("p.txt");
  542.                         rename("temp.dat","p.txt");
  543.                         c.displaycandet();
  544.                         goto h;
  545.                     }
  546.                 }
  547.             }
  548.             else if(strcmp(c.clas.s)==0)
  549.             {
  550.                 while(f1.read((char*)&a.sizeof(a)))
  551.                 {
  552.                     if(a.tno=c.tno)
  553.                     {
  554.                         a.c2=a.c2+c.nosc;
  555.                         d=a.d;
  556.                         m=a.m;
  557.                         addr=f1.teelg();
  558.                         ad=sizeof(a.c2);
  559.                         f1.seekp(addr-(5*ad));
  560.                         f1.write((char*)&a.c2,sizeof(a.c2));
  561.                         t.amt=b.amc;
  562.                         if((c.d==d)&&(c.m==m))
  563.                         {
  564.                             cout<<"you are cancelling at the date of departure"<<endl;
  565.                             a.amr=t.amt-((t.amt*60)/100);
  566.                         }
  567.                         else if(c.m==m)&&(c.d<d))
  568.                         {
  569.                             cout<<"you are cancelling at the month of deperture"<<endl;
  570.                             c.amr=t.amt-((t.amt*50)/100);
  571.                         }
  572.                         else if(m>c.m)
  573.                         {
  574.                             cout<<"you are cancelling"<<m-c.m<<"month before the date of departure"<<endl;
  575.                             c.amr=t.amt-((t.amt+20)/100);
  576.                         }
  577.                         else
  578.                         {
  579.                             cout<<"you are cancelling after the departure"<<endl;
  580.                             cout<<"your request cannot be completed"<<wndl;
  581.                         }
  582.                         fstream fp2;
  583.                         fp2.open("Temp.dat",ios::out);
  584.                         f2.seekg(0,ios::beg));
  585.                         while(f2.read((char*)&b.sizeof(b)))
  586.                         {
  587.                             if(b.pnr!=c.pnr)
  588.                             {
  589.                                 fp2.write((char*)&b.sizeof(b));
  590.                             }
  591.                         }
  592.                         fp2.close();
  593.                         remove("p.txt");
  594.                         rename("Temp.dat","p.txt");
  595.                         c.displaycancdet();
  596.                         goto h;
  597.                     }
  598.                 }
  599.             }
  600.         }
  601.         else
  602.         {
  603.             flag=0;
  604.         }
  605.     }
  606.     h;
  607.     if(flag==0)
  608.     {
  609.         cout<<"\nEnter the correct pnr number \n";
  610.     }
  611.     f1.close();
  612.     f2.close();
  613.     f3.close();
  614.  
  615. }
  616. void can()
  617. {
  618.     int ch;
  619.     do
  620.     {
  621.  
  622.         cout<<"............................................................\n";
  623.         cout<<"CANCELLATION MENU";
  624.         cout<<"...........................................................\N";
  625.         cout<<"\n\n1.Cancel\n\n2.Return to main menu\n";
  626.         cout<<"\nEnter your choice\n";
  627.         cin>>ch;
  628.         cout<<endl;
  629.         switch(ch)
  630.         {
  631.             case 1:
  632.                 cancel();
  633.                 break;
  634.         }
  635.     }
  636.     while(ch==1);
  637.  
  638. }
  639. void user()
  640. {
  641.     login a;
  642.     int ch;
  643.     cout<<"\n........................................................\n";
  644.     cout<<"      USER MENU      \n";
  645.     cout<<"..........................................................\n";
  646.     char*password;
  647.     fstream f;
  648.     f.open("id.txt",ios::in||ios::out||ios::binary);
  649.     cahr id[100];
  650.     cout<<"\n\n  Enter your ID:";gets(id);
  651.     password=getpass("\n\n Enter your password:");
  652.     while(f.read((char*)&a.sizeof(a)))
  653.     {
  654.         if((strcmp(a.id.id)==0)&&(strcmp(a.pass,p.password)==0))
  655.         {
  656.             do
  657.                 {
  658.                     cout<<"\n\n1.Reserve aticket \n\n2.Cancel a ticket";
  659.                     cout<<"\n\n3.Enquiry \n\n4.Return to main menu\n";
  660.                     cout<<"\nEnter your choice:";
  661.                     cin>>ch;
  662.                     cout<<endl;
  663.                     switch(ch);
  664.                     {
  665.                         case 1:
  666.                             reserve();
  667.                             break;
  668.                         case 2:
  669.                             cancel();
  670.                             break;
  671.                         case 3:
  672.                             enquiry();
  673.                             break;
  674.                     }
  675.                 }
  676.             while(ch>=3)
  677.             goto j;
  678.         }
  679.         else
  680.         {
  681.             d=1;
  682.         }
  683.     }
  684.     if(d==1)
  685.     {
  686.         cout<<"\nEnter user id and password correct \n";
  687.     }
  688. }
  689. void manage()
  690. {
  691.     int ch;
  692.     fstream f;
  693.     char c;
  694.     login a;
  695.     cout<<"...................................................................\n";
  696.     cout<<"WELCOME TO USER MANAGEMENT MENU\N";
  697.     cout<<"...................................................................\N";
  698.     do
  699.     {
  700.         cout<<"\n\n1.add ID details of user \n";
  701.         cout<<"\n2.Display details of Id \n\n3.return to main menu \n";
  702.         cout<<"\nEnter your choice :";
  703.         cin>>Ch;
  704.         cout<<endl;
  705.         switch(ch)
  706.         {
  707.             case 1:
  708.                 f.open("id.txt",ios::in||ios::out||ios::binary||ios::app);
  709.                 do
  710.                 {
  711.                     a.getid();
  712.                     f.write((char*)&a.sizepf(a));
  713.                     cout<<"\n\nDo you want to add one more record\n";
  714.                     cout<<"y-Yes\nn-No\n";
  715.                     cout<<"Your answer \n";
  716.                     cin>>c;
  717.                 }while(c=='Y');
  718.                 f.close();
  719.                 break;
  720.             case 2:
  721.                 f.open("id.txt",ios::in||ios::out||ios::binary);
  722.                 f.seekg(0);
  723.                 while((f.read((char*)&a.sizeof(a)))
  724.                 {
  725.                     a.displayid();
  726.                 }
  727.                 f.close();
  728.                 break;
  729.         }
  730.     }
  731.     while(ch<=2;)
  732. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement