14952015 railway reservation in c

Upload: ashuashly

Post on 30-May-2018

229 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/14/2019 14952015 Railway Reservation in C

    1/32

    #include #include #include #include#include #include #include #include charf[10]="f"; char s[10]="s"; int addr,ad,flag,f1,d,m,i,amt; float tamt; class login{ public: char id[100]; char pass[100]; char *password; void getid(){ cout

  • 8/14/2019 14952015 Railway Reservation in C

    2/32

    int d,m,y; void getdetail() { couty; } void displaydetail(){ cout

  • 8/14/2019 14952015 Railway Reservation in C

    3/32

    { cout

  • 8/14/2019 14952015 Railway Reservation in C

    4/32

    cout

  • 8/14/2019 14952015 Railway Reservation in C

    5/32

    for(i=0;i

  • 8/14/2019 14952015 Railway Reservation in C

    6/32

    break; case 2: user(); break; case 3: exit(0); } }while(ch

  • 8/14/2019 14952015 Railway Reservation in C

    7/32

    { case 1: f.open("t.txt",ios::out|ios::binary); do { a.getdetail(); f.write((char*) & a,sizeof(a)); cout

  • 8/14/2019 14952015 Railway Reservation in C

    8/32

    } void reserve() { int ch; do { cout

  • 8/14/2019 14952015 Railway Reservation in C

    9/32

    ad=sizeof(a.c1); f1.seekp(addr-(7*ad)); a.c1=a.c1-b.nosr; f1.write((char *) &a.c1,sizeof(a.c1)); if(b.con==1) { cout

  • 8/14/2019 14952015 Railway Reservation in C

    10/32

    { if(a.c2>=b.nosr) { amt=a.c2fare; addr=f1.tellg(); ad=sizeof(a.c2);f1.seekp(addr-(5*ad)); a.c2=a.c2-b.nosr; f1.write((char *) & a.c2,sizeof(a.c2));if(b.con==1) { cout

  • 8/14/2019 14952015 Railway Reservation in C

    11/32

    } } getch(); goto h; } else { flag=0; } } if(flag==0) { cout

  • 8/14/2019 14952015 Railway Reservation in C

    12/32

    while(f.read((char *) & a,sizeof(a))) { a.displaydetail(); } getch(); } voidcancell() { detail a; reser b; canc c; fstream f1,f2,f3; f1.open("t.txt",ios::in|ios::out|ios::binary); f2.open("p.txt",ios::in|ios::out|ios::binary);f3.open("cn.txt",ios::in|ios::out|ios::binary); cout

  • 8/14/2019 14952015 Railway Reservation in C

    13/32

    d=a.d; m=a.m; addr=f1.tellg(); ad=sizeof(a.c1); f1.seekp(addr-(7*ad));f1.write((char *) & a.c1,sizeof(a.c1)); tamt=b.amc; if((c.d==d)&&(c.m==m)){ cout

  • 8/14/2019 14952015 Railway Reservation in C

    14/32

    d=a.d; m=a.m; addr=f1.tellg(); ad=sizeof(a.c2); f1.seekp(addr-(5*ad));f1.write((char *) & a.c2,sizeof(a.c2)); tamt=b.amc; if((c.d==d)&&(c.m==m)){ cout

  • 8/14/2019 14952015 Railway Reservation in C

    15/32

    if(flag==0) { cout

  • 8/14/2019 14952015 Railway Reservation in C

    16/32

    puts("Enter your id:");gets(id); password=getpass("Enter your password:");while(f.read((char *) & a,sizeof(a))){ if((strcmp(a.id,id)==0)&&(strcmp(a.pass,password)==0)) { do{ cout

  • 8/14/2019 14952015 Railway Reservation in C

    17/32

    void manage() { int ch; fstream f; char c; login a; cout

  • 8/14/2019 14952015 Railway Reservation in C

    18/32

    a.displayid(); } f.close(); break; } }while(ch

  • 8/14/2019 14952015 Railway Reservation in C

    19/32

    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ .......WELCOME TO RAILWAYRESERVATION SYSTEM.....................~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^^^^^^^^^^^^^^^^^^^^^^MAINMENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode 2.User mode 3.Exit Enter yourchoice:1 Enter the admininistrator password:********* Enter the password correctlyYou are not permitted to logon this mode ^^^^^^^^^^^^^^^^^^^^^^MAINMENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode 2.User mode 3.Exit Enter yourchoice:1 Enter the admininistrator

    password:********* .............................ADMINISTRATORMENU......................................... 1.Create detail data base 2.Adddetails 3.Display details 4.User management 5.Display passenger details 6.Returnto main menu Enter your choice:1

    Enter the details as follows Train no:123 Train name:yercaud exp

  • 8/14/2019 14952015 Railway Reservation in C

    20/32

    Boarding point:erode Destination pt:chennai No of seats in first class & fare perticket:100 200 No of seats in second class & fare per ticket:200 100 Date oftravel:2 3 2009 Do you want to add one more record? y-for Yes n-for No y Enter thedetails as follows Train no:124 Train name:shatapti exp Boarding point:chennaiDestination pt:bombay No of seats in first class & fare per ticket:300 200 No ofseats in second class & fare per ticket:200 300 Date of travel:4 5 2009 Do youwant to add one more record? y-for Yes n-for No n.............................ADMINISTRATOR

    MENU.................................... 1.Create detail data base 2.Add details3.Display details 4.User management 5.Display passenger details 6.Return to mainmenu Enter your choice:2

    Enter the details as follows Train no:126 Train name:kurula exp Boardingpoint:bombay

  • 8/14/2019 14952015 Railway Reservation in C

    21/32

    Destination pt:chennai No of seats in first class & fare per ticket:200 300 No ofseats in second class & fare per ticket:300 200 Date of travel:4 32009 .............................ADMINISTRATORMENU....................................... 1.Create detail data base 2.Adddetails 3.Display details 4.User management 5.Display passenger details 6.Returnto main menu Enter your choice:3 Trno Trname Bpt Dest Fs Ffare Ss Sfare Date ofdep 123 124 126 yercaud exp shatapti exp kurula exp erode chennai 100 chennaibombay 300 bombay chennai 200 200 200 300 200 200 300 100 300 200 2-3-2009 4-5-

    2009 4-3-2009

    .............................ADMINISTRATORMENU................................................. 1.Create detail data base2.Add details 3.Display details 4.User management 5.Display passenger details6.Return to main menu Enter your choice:4

    ..........WELCOME TO THE USER MANAGEMENT MENU........ 1.Create id data base2.Add details 3.Display details

  • 8/14/2019 14952015 Railway Reservation in C

    22/32

    4.Return to the main menu Enter your choice:1 Enter your id:ashwin Enter thepassword:********** Do you want to add one more record y-Yes n-No y Enter yourid:ajinth Enter the password:********** Do you want to add one more record y-Yesn-No y Enter your id:bala Enter the password:******** Do you want to add one morerecord y-Yes n-No y Enter your id:hemanth Enter the password:********* Do you wantto add one more record y-Yes n-No n 1.Create id data base 2.Add details 3.Displaydetails 4.Return to the main menu Enter your choice:2 Enter your id:berlin Enterthe password:********* 1.Create id data base 2.Add details

  • 8/14/2019 14952015 Railway Reservation in C

    23/32

    3.Display details 4.Return to the main menu Enter your choice:3 Id:ashwinPassword:11111111 Id:ajinth Password:22222222 Id:bala Password:33333333 Id:premPassword:44444444 Id:hemanth Password:55555555 Id:berlin Password:666666661.Create id data base 2.Add details 3.Display details 4.Return to the main menuEnter your choice:4 . .............................ADMINISTRATORMENU........................ 1.Create detail data base 2.Add details 3.Displaydetails 4.User management 5.Display passenger details 6.Return to main menu Enteryour choice:5 .

    .............................ADMINISTRATOR MENU...................................1.Create detail data base 2.Add details 3.Display details

  • 8/14/2019 14952015 Railway Reservation in C

    24/32

    4.User management 5.Display passenger details 6.Return to main menu Enter yourchoice:6 ^^^^^^^^^^^^^^^^^^^^^^MAIN MENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Adminmode 2.User mode 3.Exit Enter your choice:2**********************************************************************************WELCOME TO THE USER MENU******************************************************************************************** Enteryour id: ashwin Enter your password:********* Enter your user id and passwordcorrectly ^^^^^^^^^^^^^^^^^^^^^^MAIN MENU^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode

    2.User mode 3.Exit Enter your choice:2********************************************************************************WELCOME TO THE USER MENU**************************************************************************************** Enter yourid: ashwin Enter your password:********* 1.Reserve 2.Cancell 3.Enquiry 4.Return tothe main menu Enter your choice:1 1.Reserve 2.Return to the main menu Enter yourchoice:1 Enter the details as follows

  • 8/14/2019 14952015 Railway Reservation in C

    25/32

    Train no:123 Train name:yercaud Boarding point:erode Destination pt:chennai No ofseats required:10 Passenger name:raja Passenger age:45 Passenger name:raguPassenger age:32 Passenger name:ravi Passenger age:34 Passenger name:vinothPassenger age:23 Passenger name:raju Passenger age:24 Passenger name:lathaPassenger age:45 Passenger name:mala Passenger age:23 Passenger name:vimalaPassenger age:32 Passenger name:kathir Passenger age:12 Passenger name:kosiPassenger age:43 Enter the class f-first class s-second class:f Date of travel:2 22009 Enter the concession category 1.Military 2.Senior citizen 3.Children below 5

    yrs 4.None 4 ..................................END OF GETTINGDETAILS.............................. You cannot get anyconcession ..............................................................................................................

  • 8/14/2019 14952015 Railway Reservation in C

    26/32

    ..................................................................................

    ............................. Pnr no:10770 Train no:123 Train name:yercaudBoarding point:erode Destination pt:chennai No of seats reserved:10Passengername:raja Passenger age:45Passenger name:ragu Passenger age:32Passenger name:raviPassenger age:34Passenger name:vinoth Passenger age:23Passenger name:rajuPassenger age:24Passenger name:latha Passenger age:45Passenger name:mala Passengerage:23Passenger name:vimala Passenger age:32Passenger name:kathir Passengerage:12Passenger name:kosi Passenger age:43 Your class:f Date of reservation:2-2-

    2009 Your concession category:4 You must pay:2000************************************************************************************* ......................................END OFRESERVATION........................................*************************************************************************************---------------------------------------------------------------------------------------------------------------------------------------Your ticket isreserved-----------------------------------------------------------------------Endof reservation menu------------------------------1.Reserve 2.Return to the mainmenu Enter your choice:2

    1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu

  • 8/14/2019 14952015 Railway Reservation in C

    27/32

    Enter your choice:3 Trno 123 124 126 Trname yercaud exp shatapti exp kurula expBpt Dest Fs Ffare 200 200 300 Ss 200 200 300 Sfare Date of dep 100 300 200 2-3-2009 4-5-2009 4-3-2009

    erode chennai 90 chennai bombay 300 bombay chennai 200

    1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu Enter your choice:2*********************************CANCELLATION MENU******************************

    Enter the details as follows Pnr no:10770 Date of cancellation:2 32009 ..............................................END OF GETTINGDETAILS..................................... You are cancelling at the date ofdeparture .................................................................................................................................. ...................................................................................................................................

    Pnr no:10770 Train no:123 Train name:yercaud

  • 8/14/2019 14952015 Railway Reservation in C

    28/32

    Boarding point:erode Destination pt:chennai Your class:f no of seats to becancelled:10 Passenger name: raja passenger age: 45 Passenger name: ragu passengerage: 32 Passenger name: ravi passenger age: 34 Passenger name: vinoth passengerage: 23 Passenger name: raju passenger age: 24 Passenger name: latha passengerage:45 Passenger name: mala passenger age: 23 Passenger name: vimala passengerage: 32 Passenger name: kathir passenger age: 12 Passenger name: kosi passengerage: 43 Date of cancellation:2-3-2009 You can collect: 800rs*********************************************************************************

    ..........END OF CANCELLATION................................*********************************************************************************1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu Enter your choice:2**************************CANCELLATION MENU*************************** Enter thedetails as follows Pnr no:12234 Date of cancellation:2 3 2009 ............ENDOF GETTING DETAILS...................................... Enter the correct pnr no

    1.Reserve 2.Cancell 3.Enquiry

  • 8/14/2019 14952015 Railway Reservation in C

    29/32

    4.Return to the main menu Enter your choice:3 Trno 123 124 126 Trname yercaud expshatapti exp kurula exp Bpt Dest Fs Ffare 200 200 300 Ss 200 200 300 Sfare Date ofdep 100 300 200 2-3-2009 4-5-2009 4-3-2009

    erode chennai 100 chennai bombay 300 bombay chennai 200

    1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu Enter your choice:3 Trno123 124 126 Trname yercaud exp shatapti exp kurula exp Bpt Dest Fs Ffare 200 200

    300 Ss 200 200 300 Sfare Date of dep 100 300 200 2-3-2009 4-5-2009 4-3-2009

    erode chennai 100 chennai bombay 300 bombay chennai 200

    1.Reserve 2.Cancell 3.Enquiry 4.Return to the main menu Enter your choice:11.Reserve 2.Return to the main menu Enter your choice:1 Enter the details asfollows

  • 8/14/2019 14952015 Railway Reservation in C

    30/32

    Train no:12345 Train name:shatapti Boarding point:chennai Destination pt:bombay Noof seats required:1 Passenger name:raja Passenger age:23 Enter the class f-firstclass s-second class:f Date of travel:3 2 2009 Enter the concession category1.Military 2.Senior citizen 3.Children below 5 yrs 4.None4 .....................................END OF GETTINGDETAILS................................... ............Wrong trainno...................................................................Enter the train no from the data base.........................

    1.Reserve 2.Return to the main menu Enter your choice:2 1.Reserve 2.Cancell3.Enquiry 4.Return to the main menu Enter your choice:4^^^^^^^^^^^^^^^^^^^^^^^MAIN MENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode2.User mode 3.Exit ^^^^^^^^^^^^^^^^^^^^^^MAINMENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode 2.User mode 3.Exit

  • 8/14/2019 14952015 Railway Reservation in C

    31/32

    Enter your choice:1 Enter the admininistratorpassword:********* .............................ADMINISTRATORMENU.................................... 1.Create detail data base 2.Add details3.Display details 4.User management 5.Display passenger details 6.Return to mainmenu Enter your choice:5 . .............................ADMINISTRATORMENU................................... 1.Create detail data base 2.Add details3.Display details 4.User management 5.Display passenger details 6.Return to mainmenu Enter your choice:6 ^^^^^^^^^^^^^^^^^^^^^^MAIN

    MENU^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 1.Admin mode 2.User mode 3.Exit Enter yourchoice:3

  • 8/14/2019 14952015 Railway Reservation in C

    32/32