codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#include<conio.h> #include<iostream.h> #include<stdlib.h> #include<string.h> #include<fstream.h> //#include<graphics.h> void record(); void search(); void pnr_search(); int choice,i=0,a,j,f,k; int chk=0; char r,ch,c; int count=0; char name[15],pr[8]; const int size=6; char cnfrm[7]; double isl=22000,lhe=20000,khi=12000; struct twikid { char day[10]; int d; int m; int y; char from[15]; char to[15]; char time[20]; char clas[15]; char fname[15]; char lname[15]; char ppt_no[15]; char cont[15]; char meal[10]; char type[10]; int seat; long double adult; long double child; long double infant; char prefix[7]; int bd; int bm; int by; int ed; int em; int ey; char rdate[15]; long double price; char pnr[8]; char tkt[8]; long double tprice; long double tax; long double amount; }p1[20]; // ofstream thefile("ID.txt"); void gen_ren(char *s, const int len) { static const char alphanum[] = "0123456789" "ABCDEFGHIJKLMNOPQRSTUVWXYZ"; for ( k = 0; k < len; ++k) { s[k] = alphanum[rand() % (sizeof(alphanum) - 1)]; } s[len] = 0; } void tkt_num(char *s, const int ben) { static const char alphanum[] = "0123456789"; for ( k = 0; k < ben; ++k) { s[k] = alphanum[rand() % (sizeof(alphanum) - 1)]; } s[ben] = 0; } // void cinfo() // { // gen_ren(captcha,size); // cout<<captcha<<"\n\nEnter this captcha to confirm your reservation : "; // cin>>cnfrm; // } void menu() { clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tWelcome to the Twikid Airline"; cout<<"\n\n\t\t\t*********************************\n"; cout<<"\t\t\tPress 1\t to Enter a New Record\n"; cout<<"\t\t\tPress 2\t to Remove Record\n"; cout<<"\t\t\tPress 3\t to Search by Name\n"; cout<<"\t\t\tPress 4\t to Search by PNR Number\n"; cout<<"\t\t\tPress 5\t to View all Record\n"; cout<<"\t\t\tPress 6\t to Input data from File\n"; cout<<"\t\t\tPress 7\t to Exit\n"; cout<<"\t\t\t*********************************\n"; } int main() { //textbackground(1); //textcolor(2); clrscr(); p1[i].adult=0; p1[i].child=0; p1[i].infant=0; int in; do{ menu(); if(getch()=='1') { do { clrscr(); record(); i++; cout<<"\n\nPress 'r' for more entry or any other key to exit"; } while(getch()=='r'); } if(getch()=='2') k=1; for(j=0;j<k;j++) { search(); if(chk=1) { k++; } else cout<<"\n\nPress y to confirm or any other key to exit"; if(getch()=='y') { p1[i].day=="00"; p1[i].d=00; p1[i].m=00; p1[i].y=00; p1[i].from=="Nil"; p1[i].to=="00"; p1[i].time=="00"; p1[i].clas=="00"; p1[i].fname=="00"; p1[i].lname=="00"; p1[i].ppt_no=="00"; p1[i].cont=="00"; p1[i].meal=="00"; p1[i].type=="00"; p1[i].seat=00; p1[i].adult=00; p1[i].child=00; p1[i].infant=00; p1[i].prefix=="00"; p1[i].bd=00; p1[i].bm=00; p1[i].by=00; p1[i].ed=00; p1[i].em=00; p1[i].ey=00; p1[i].rdate=="00"; p1[i].price=00; p1[i].pnr=="00"; p1[i].tkt=="00"; p1[i].tprice=00; p1[i].tax=00; p1[i].amount=00; cout<<"\n\n\n\n\t\t\tRecord is removed!!"; } } if(getch()=='3') { search(); } if(getch()=='4') { pnr_search(); } //char a; //ifstream infile("rule.txt"); //while(infile.get(a)!=0) //cout<<a; cout<<"\n\nPress 'm' to return to Main menu"; } while(getch()=='m'); } void record() { cout<<"\n\n\n\nOur flight are available in;\n\n1:Islamabad\n2:Karachi\n3:Lahore\n4:Dubai\n\n\t\t\tPress Enter to Proceed\n\n"; getch(); clrscr(); k=1; for(j=0;j<k;j++) { cout<<"\n\n\nChoose your flight\n\nPress 1 for Islamabad to Dubai\nPress 2 for Karachi to Dubai\nPress 3 for Lahore to Dubai\n\n"; if(getch()=='1') { strcpy(p1[i].from,"Islamabad"); strcpy(p1[i].to,"Dubai"); p1[i].price=isl; } else if(getch()=='2') { strcpy(p1[i].from,"Karachi"); strcpy(p1[i].to,"Dubai"); p1[i].price=khi; } else if(getch()=='3') { strcpy(p1[i].from,"Lahore"); strcpy(p1[i].to,"Dubai"); p1[i].price=lhe; } else { k++; cout<<"\t\tInvalid Entry!! Try again..."; } } cout<<"\n\nWhen do you want to travel?\nEnter Day!! "; cin.get(p1[i].day,10); cin.ignore(); while(p1[i].y<2011) { cout<<"\n\nEnter Date : \ne.g(dd-mm-yyyy)\n\n"; cin>>p1[i].d>>ch>>p1[i].m>>ch>>p1[i].y; cin.ignore(); if (p1[i].d<1 || p1[i].d>31) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].m<1 || p1[i].m>12) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].y<2011) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; } k=1; for(j=0;j<k;j++) { cout<<"\n\nPress 1 for Return and 2 for One way : "; if(getch()=='1') { strcpy(p1[i].type,"Return"); p1[i].price=p1[i].price+(p1[i].price*60/100); cout<<"\n\nEnter Return Date : "; cin.get(p1[i].rdate,15); cin.ignore(); } else if(getch()=='2') strcpy(p1[i].time,"One Way"); else { k++; cout<<"\t\tInvalid Entry!! Try again..."; } } k=1; for(j=0;j<k;j++) { cout<<"\n\nTwo flights are available on "<<p1[i].day<<" from "<<p1[i].from<<" to "<<p1[i].to<<"\nWhen do you want to travel??\n\nPress 1 for Morning at 0800\n\nPress 2 for Evening at 1700\n\n"; if(getch()=='1') strcpy(p1[i].time,"Morning at 0800"); else if(getch()=='2') strcpy(p1[i].time,"Evening at 1700"); else { k++; cout<<"\t\tInvalid Entry!! Try again..."; } } k=1; for(j=0;j<k;j++) { cout<<"\n\nChoose your Class :\nPress 1 for Economy class\nPress 2 for Lower Economy Class class\nPress 3 for Business class\n\n"; if(getch()=='1') strcpy(p1[i].clas, "Economy Class"); else if(getch()=='2') { strcpy(p1[i].clas,"Lower Economy Class"); p1[i].price=p1[i].price*80/100; } else if(getch()=='3') { strcpy(p1[i].clas,"Business Class"); p1[i].price=p1[i].price+(p1[i].price*80/100); } else { k++; cout<<"\t\tInvalid Entry!! Try again..."; } } cout<<"How many seats you want to reserve? "; int adult,child,infant; cin>>p1[i].seat; cout<<"Adults : "; cin>>adult; cout<<"Childrens : "; cin>>child; cout<<"Infants : "; cin>>infant; clrscr(); cout<<"Seats are Available"; cout<<"\n\n\n\nEconomy Class :\t 7 Seats are available"; cout<<"\n\nLower Economy Class :\t 9 Seats are available"; cout<<"\n\nBusiness Class :\t 4 Seats are available"; p1[i].adult=adult*p1[i].price; p1[i].child=child*(p1[i].price*60/100); p1[i].infant=infant*(p1[i].price*25/100); p1[i].tprice=p1[i].adult+p1[i].child+p1[i].infant; p1[i].tax=p1[i].tprice*21/100; p1[i].amount=p1[i].tprice+p1[i].tax; clrscr(); cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t"<<adult<<" Adults : "<<p1[i].adult<<"\n\n\t\t\t"<<child<<" Child : "<<p1[i].child<<"\n\n\t\t\t"<<infant<<" Infants : "<<p1[i].infant<<"\n\n\t\t\tNet Amount : "<<p1[i].tprice<<"\n\n\t\t\tTax : "<<p1[i].tax<<"\n\n\t\t\t Total Amount : "<<p1[i].amount; cout<<"\n\n\t\t\tPress Enter to Proceed"; getch(); clrscr(); for(j=0;j<p1[i].seat;j++) { cout<<"\n\nPrefix\n\nMr. \Mrs. \Ms. \Miss. \Child. \Infant\n\nEnter here : "; cin>>p1[i].prefix; cin.ignore(); cout<<"\nEnter Your First Name : "; cin.get(p1[i].fname,15); cin.ignore(); cout<<"\nEnter Your Last Name : "; cin.get(p1[i].lname,15); cin.ignore(); while(p1[i].by>2011 || p1[i].by<1920) { cout<<"Enter date of Birth : \ne.g(dd-mm-yyyy)\n\n"; cin>>p1[i].bd>>ch>>p1[i].bm>>ch>>p1[i].by; cin.ignore(); if (p1[i].bd<1 || p1[i].bd>31) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].bm<1 || p1[i].bm>12) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].by>2011 || p1[i].by<1920) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; } cout<<"Enter Your Passport Number : "; cin.get(p1[i].ppt_no, 15); cin.ignore(); while(p1[i].ey<2013) { cout<<"Enter Passport Expiry date : \ne.g(dd-mm-yyyy)\n\n"; cin>>p1[i].ed>>ch>>p1[i].em>>ch>>p1[i].ey; cin.ignore(); if (p1[i].ed<1 || p1[i].ed>31) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].em<1 || p1[i].em>12) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(p1[i].ey<1920) cout<<"\n\t!! Error, Logical Error.. !!"; else if(p1[i].ey<2011 || p1[i].ey>2020) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; } cout<<"Enter Your Contact # "; cin.get(p1[i].cont,15); cin.ignore(); k=1; for(j=0;j<k;j++) { cout<<"Choose your Meal type\n\nPress 1 for Veg\nPress 2 for Non-Veg\nPress 3 for Baby Food\n"; if(getch()=='1') strcpy(p1[i].meal,"Veg"); else if(getch()=='2') strcpy(p1[i].meal,"Non-Veg"); else if(getch()=='3') strcpy(p1[i].meal,"Baby Food"); else { k++; cout<<"\t\tInvalid Entry!! Try again..."; } } clrscr(); cout<<"\n\nDay : "<<p1[i].day<<"\nFlight Date : "<<p1[i].d<<ch<<p1[i].m<<ch<<p1[i].y<<"\nFlight Type : "<<p1[i].type<<"\nReturn Date : "<<p1[i].rdate<<"\nDeparture Place : "<<p1[i].from<<"\nDestination : "<<p1[i].to<<"\nClass Type : "<<p1[i].clas<<"\nTime of Flight : "<<p1[i].time<<"\nTitle : "<<p1[i].prefix<<"\nFirst Name : "<<p1[i].fname<<"\nLast Name : "<<p1[i].lname<<"\nDate of Birth : "<<p1[i].bd<<ch<<p1[i].bm<<ch<<p1[i].by<<"\nPassport Number : "<<p1[i].ppt_no<<"\nExpiry Date : "<<p1[i].ed<<ch<<p1[i].em<<ch<<p1[i].ey<<"\n Contact Number : "<<p1[i].cont<<"\nMeal Type : "<<p1[i].meal<<"\n\n"; cout<<"\n\nPress y to confirm or n to modify : "; if(getch()=='y') { clrscr(); gen_ren(p1[i].pnr,size); cout<<"\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\t\t\tYour PNR Number is : "<<p1[i].pnr<<endl; cout<<"\n\n\n\t\t\tWould you like to book a ticket?\n\n\t\tPress y to proceed or any other key to exit"; } if(getch()=='y') { clrscr(); cout<<"\n\nChoose Your Paymet method\n\nPress 1 for Credit Card\nPress 2 for Cash : "; } if(getch()=='1') { clrscr(); char cnum[18]; int cvv; int dbd,dbm,dby; cout<<"\nEnter Name : "; cin.get(name,15); cin.ignore(); while(dby>2011 || dby<1920) { cout<<"Enter date of Birth : \ne.g(dd-mm-yyyy)\n\n"; cin>>dbd>>ch>>dbm>>ch>>dby; cin.ignore(); if (dbd<1 || dbd>31) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(dbm<1 || dbm>12) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(dby>2011 || dby<1920) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else cout<<" "; } while(count!=16) { cout<<"\n\nEnter 16 digit credit card number : "; cin>>cnum; for(count=0;cnum[count]!='\0';count++) cout<<" "; if(count!=16) cout<<"\n\t!! Error, Sorry you have entered invalid number, please try again.. !!"; } cout<<"\n\nEnter cvv num : "; cin>>cvv; int dd,mm,yy; while(yy<2013) { cout<<"Enter Card Expiry date : \ne.g(dd-mm-yyyy)\n\n"; cin>>dd>>ch>>mm>>ch>>yy; cin.ignore(); if (dd<1 || dd>31) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(mm<1 || mm>12) cout<<"\n\t!! Error, Sorry you have entered invalid date, please try again.. !!"; else if(yy<1920) cout<<"\n\t!! Error, Logical Error.. !!"; else if(yy<2013) cout<<"\n\t!! Error, Sorry We can not accpet the card of this Expiry.. !!"; else cout<<" "; } } else if(getch()=='2') break; else { clrscr(); cout<<"\n\n\t\t!!Invalid Entry!!"; } } cout<<"\n\nPress y to confirm or any other key to exit : "; if(getch()=='y') { clrscr(); cout<<"\n\n\n\n\n\t\tThe Amount of "<<p1[i].amount<<" is received\n\n\t\tPress any key to see ticket Number :"; getch(); tkt_num(p1[i].tkt,size); cout<<"\n\n\n\t\tYour ticket Number is : "<<p1[i].tkt<<endl; } // ofstream thefile("ID.txt" , ios::app); // thefile<<"\n\nDay : "<<p1[i].day<<"\nFlight Date : "<<p1[i].date<<"\nFlight Type : "<<p1[i].type<<"\nReturn Date : "<<p1[i].rdate<<"\nDeparture Place : "<<p1[i].from<<"\nDestination : "<<p1[i].to<<"\nClass Type : "<<p1[i].clas<<"\nTime of Flight : "<<p1[i].time<<"\nTitle : "<<p1[i].prefix<<"\nFirst Name : "<<p1[i].fname<<"\nLast Name : "<<p1[i].lname<<"\nDate of Birth : "<<p1[i].dob<<"\nPassport Number : "<<p1[i].ppt_no<<"\nExpiry Date : "<<p1[i].edate<<"\n Contact Number : "<<p1[i].cont<<"\nMeal Type : "<<p1[i].meal<<"\n\n------------------------------"; // ofstream thefile("ID.txt" , ios::app); // thefile<<"\n\n\n\nTotal Amount : "<<p1[i].amount; getch(); } void search() { cout<<"\n\nEnter First Name to Search the data : "; cin>>name; for(count=0;name[count]!='\0';count++) cout<<" "; for(i=0;i<20;i++) { while(name[f]!='\0') { if(name[f]==p1[i].fname[f]) { f++; cout<<" "; } else break; } if(f==count) { clrscr(); cout<<"\n\nDay : "<<p1[i].day<<"\nFlight Date : "<<p1[i].d<<ch<<p1[i].m<<ch<<p1[i].y<<"\nFlight Type : "<<p1[i].type<<"\nReturn Date : "<<p1[i].rdate<<"\nDeparture Place : "<<p1[i].from<<"\nDestination : "<<p1[i].to<<"\nClass Type : "<<p1[i].clas<<"\nTime of Flight : "<<p1[i].time<<"\nTitle : "<<p1[i].prefix<<"\nFirst Name : "<<p1[i].fname<<"\nLast Name : "<<p1[i].lname<<"\nDate of Birth : "<<p1[i].bd<<ch<<p1[i].bm<<ch<<p1[i].by<<"\nPassport Number : "<<p1[i].ppt_no<<"\nExpiry Date : "<<p1[i].ed<<ch<<p1[i].em<<ch<<p1[i].ey<<"\n Contact Number : "<<p1[i].cont<<"\nMeal Type : "<<p1[i].meal<<"\n\n"; break; } else { chk=1; f=0; } } if(chk=1) cout<<"\n\n\t\tSorry Record not found Try again..."; } void pnr_search() { f=0; cout<<"Enter PNR to Search the data : "; cin>>pr; for(count=0;pr[count]!='\0';count++) cout<<" "; for(i=0;i<20;i++) { while(pr[f]!='\0') { if(pr[f]==p1[i].pnr[f]) { f++; cout<<" "; } else break; } if(f==count) { clrscr(); cout<<"\n\nDay : "<<p1[i].day<<"\nFlight Date : "<<p1[i].d<<ch<<p1[i].m<<ch<<p1[i].y<<"\nFlight Type : "<<p1[i].type<<"\nReturn Date : "<<p1[i].rdate<<"\nDeparture Place : "<<p1[i].from<<"\nDestination : "<<p1[i].to<<"\nClass Type : "<<p1[i].clas<<"\nTime of Flight : "<<p1[i].time<<"\nTitle : "<<p1[i].prefix<<"\nFirst Name : "<<p1[i].fname<<"\nLast Name : "<<p1[i].lname<<"\nDate of Birth : "<<p1[i].bd<<ch<<p1[i].bm<<ch<<p1[i].by<<"\nPassport Number : "<<p1[i].ppt_no<<"\nExpiry Date : "<<p1[i].ed<<ch<<p1[i].em<<ch<<p1[i].ey<<"\n Contact Number : "<<p1[i].cont<<"\nMeal Type : "<<p1[i].meal<<"\n\n"; break; } else { chk=1; f=0; } } if(chk=1) cout<<"\n\n\t\tSorry Record not found Try again..."; }
Private
[
?
]
Run code
Submit