Comments

Friday, December 7, 2012

PROJECT: SHIP(CRUISE) MANAGEMENT SYSTEM

Posted by at 8:52 AM Read our previous post
// CODEPIRATE2012 Team
 
#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<process.h>
#include<fstream.h>
#include<ctype.h>
#include<stdlib.h>
#include<iomanip.h>
long int code;
class persdetails  //class for collecting the personal details
{
int trvlcode;
int  age[20];
char name[20][20];
char add[50];
char phnum[15];
char sex[20];
char passnum[10][10];
char familyname[30];
int num;
int numppl;
public:
void p_input(int);
void p_output();
void givefam();
int givecode();
int give();
}pob;
int persdetails::give()
{
return num;
}
void persdetails::givefam()
{
cout<<familyname;
}
int persdetails::givecode()
{
return trvlcode;
}
void persdetails::p_input(int cd)  //input func() of class1
{
trvlcode=cd;
num=0;
clrscr();
cout<<”nnt:::::::::::::::::::::: PERSONAL DETAILS ::::::::::::::::::::::n”;
cout<<”tttt~~~~~~~~~~~~~~n”;
cout<<”ntt* Please fill in the details:nnnttt1.Family Name: “;
gets(familyname);
cout<<”nttt2.Address: “;
gets(add);
cout<<”nttt3.Contact Number(10 Digit Mobile Number) : “;
gets(phnum);
cout<<”nnnttEnter The No of People Travelling: “;
cin>>numppl;
clrscr();
if(numppl>0)
{
cout<<”nttPlease Enter The Details of each Member/Members: “<<endl;
cout<<”tt                                                n”;
for(int i=0;i<numppl;i++)
{
cout<<endl<<”nttMember “<<i+1;
cout<<”ntt~~~~~~~~”;
cout<<”nnttFirst Name: “;
gets(name[i]);
cout<<”nttAge: “;
cin>>age[i];
cout<<”nttSex (M/F): “;
cin>>sex[i];
cout<<”nttPassport Number: “;
gets(passnum[i]);
if(age[i]>5)
{
num++;    //to calculate no of travellers below 5 yrs
}
}
}
}
void persdetails::p_output() //output func() of class1
{
clrscr();
cout<<”nnt ********************  PERSONAL DETAILS  ******************** ”<<endl;
cout<<”nntttFamily Name:t “<<familyname<<endl;
cout<<”tttAddress:t “<<add<<endl;
cout<<”tttPhone Number:t “<<phnum<<endl;
cout<<”nntNamettAgettSexttPassport Numbern”<<endl;
for(int i=0;i<numppl;i++)
{
cout<<”t”<<name[i]<<”tt”<<age[i]<<”tt”<<sex[i]<<”tt”<<passnum[i]<<endl;
}
getch();
}
class travdetails   //class which holds the travel details
{
int trvtcode;
int day;
int month;
int year;
int num1;
int bdg_pt;
int go_pt;
int deck;
int cabin;
int pool;
int gym;
int sports;
int salon;
int spa;
int theatre;
public:
void initial();
void t_input(int);
void t_output();
void compute();
int gtcode();
void accept(int);
}tob;
void travdetails::initial()
{
pool=gym=theatre=sports=salon=0;
}
void travdetails::accept(int c)
{
num1=c;
}
int travdetails::gtcode()
{
return trvtcode;
}
void travdetails::t_input(int cd) //input func()-class2
{
tob.initial();
trvtcode=cd;
int i=1,opt;
clrscr();
do
{
clrscr();
cout<<endl;
cout<<”nntttt_||__TRAVEL DETAILS__”;
cout<<”ntttt\___________________/”;
cout<<”ntttt~~~~~~~~~~~~~~~~~~~~~~”;
cout<<”nnttPlease enter the following details for your journey:”;
cout<<”nntt*Note:Options marked with ‘*’ are compulsory.ntttPlease do select them.”;
cout<<”nnntttt*1.Boarding Pointntttt*2.Destinationntttt*3.Date of Departurentttt*4.Deckntttt 5.Cabinntttt 6.Swimming Poolntttt 7.Gymnasuimntttt 8.Sportsntttt 9.Salonntttt 10.Spantttt 11.Theatrentttt 12.Backnntttt  “;
cin>>opt;
switch(opt)
{
case 1:clrscr();
cout<<”nnntttSelect Boarding point:nnttt1.Mumbainnttt2.Cochinnnttt3.Chennainnttt  “;
cin>>bdg_pt;
break;
case 2:clrscr();
cout<<”nnttt****** Select Destination ******nnn”;
cout<<”t 1.New Yorktt6.Dubaittt11.Antananariv”;
cout<<”nnt 2.Miamitt7.Lisbontt12.Caironn”;
cout<<”t 3.Rio De Janeirot8.Londontt13.Perth”;
cout<<”nnt 4.Colombott9.Copenhagentt14.Sydney”;
cout<<”nnt 5.Hong Kongtt10.Cape Towntt15.Wellingtonnnnnntttt   “;
cin>>go_pt;
break;
case 3:clrscr();
cout<<”nnt               Date of Departure                 ”;
cout<<”nn   * Note:Format for entering:Day(press enter)Month(press enter)Year *”;
cout<<”nnttEnter your preferred date of departure: “;
cin>>day;
gotoxy(59,7);   //to create a paricular format for entry
cout<<”/”;
cin>>month;
gotoxy(62,7);
cout<<”/”;
cin>>year;
break;
case 4:clrscr();
cout<<”nntttEnter The Choice OF Decknnttt1.Top Decknnttt2.Middle Decksnnttt3.Bottom Decknnttt  “;
cin>>deck;
break;
case 5:clrscr();
cout<<”nntttEnter The Choice Of Cabinnnttt1.ACnnttt2.Non ACnnttt  “;
cin>>cabin;
break;
case 6:clrscr();
cout<<”nnttDo You Like To Avail The Facility Of A Swimming Poolnnttt1.Nonnttt2.Yesnnttt  “;
cin>>pool;
pool–;
break;
case 7:clrscr();
cout<<”nnttDo You Like To Avail The Facility Of A Gymnasiumnnttt1.Nonnttt2.Yesnnttt  “;
cin>>gym;
gym–;
break;
case 8:clrscr();
cout<<”nnttDo You Like To Avail The Sports Facilities Offerednnttt1.Nonnttt2.Yesnnttt  “;
cin>>sports;
sports–;
break;
case 9:clrscr();
cout<<”nnttDo You Like To Avail The Facility Of Beauty Salonnnttt1.Nonnttt2.Yesnnttt  “;
cin>>salon;
salon–;
break;
case 10:clrscr();
cout<<”nntDo You Like To Avail The Facility Of Spa and Ayurvedic Treatmentnnttt1.Nonnttt2.Yesnnttt  “;
cin>>spa;
spa–;
break;
case 11:clrscr();
cout<<”nnttDo You Like To Avail The Facility Of Amphitheatrennttt1.Nonnttt2.Yesnnttt  “;
cin>>theatre;
theatre–;
break;
case 12:i=0;
break;
}
}while(i==1);
}
void boardpt(int c)  //for easy o/p
{
if(c==1)
cout<<”Mumbait”;
if(c==2)
cout<<”Cochint”;
if(c==3)
cout<<”Chennait”;
}
void dest(int d)  //for easy o/p
{
switch(d)
{
case 1:cout<<”New York”;
break;
case 2:cout<<”Miami”;
break;
case 3:cout<<”Rio De Janero”;
break;
case 4:cout<<”Colombo”;
break;
case 5:cout<<”Hong Kong”;
break;
case 6:cout<<”Dubai”;
break;
case 7:cout<<”Lisbon”;
break;
case 8:cout<<”London”;
break;
case 9:cout<<”Copenhagen”;
break;
case 10:cout<<”Cape Town”;
break;
case 11:cout<<”Antananriv”;
break;
case 12:cout<<”Cairo”;
break;
case 13:cout<<”Perth”;
break;
case 14:cout<<”Sydney”;
break;
case 15:cout<<”Willington”;
break;
}
}
void travdetails::t_output()  //output func()-class2
{
clrscr();
cout<<”nnt *******************  TRAVEL DETAILS  ********************* ”;
cout<<”nnttBoarding Point: “;
boardpt(bdg_pt);
cout<<”nnttDestination: “;
dest(go_pt);
cout<<”nnttDate of departure: “;
cout<<day<<”/”<<month<<”/”<<year;
cout<<”nnttDeck: “;
switch(deck)
{
case 1:cout<<”Top Deck”;
break;
case 2:cout<<”Middle Deck”;
break;
case 3:cout<<”Bottom Deck”;
break;
}
cout<<”nnttCabin: “;
switch(cabin)
{
case 1:cout<<”AC cabin”;
break;
case 2:cout<<”Non-AC cabin”;
break;
}
cout<<”nnntFacilities availed for are:”;
if(pool==1)
cout<<”ntttt    Swimming Pool”;
if(gym==1)
cout<<”ntttt    Gymnasuim”;
if(sports==1)
cout<<”ntttt    Sports Facilities”;
if(spa==1)
cout<<”ntttt    Spa and Ayurvedic Treatment”;
if(salon==1)
cout<<”ntttt    Beauty Salon”;
if(theatre==1)
cout<<”ntttt    Theatre”;
getch();
}
void family(int c,int&flag)  //to display familyname+to check for record
{
flag=0;
clrscr();
ifstream ifl(“PersonalDetails.txt”,ios::binary);
if(!ifl)
cout<<”nError”;
ifl.read((char*)&pob,sizeof(pob));
while(!ifl.eof())
{
if(pob.givecode()==c)
{
flag=1;
break;
}
ifl.read((char*)&pob,sizeof(pob));
}
if(flag==1)
{
cout<<”nntt ******  “;
pob.givefam();
cout<<”‘s FAMILY DATABASE  ******”;
}
else
{
cout<<”nError in locating record!!”;
}
ifl.close();
}
void editp(int c)  //to edit persdetails
{
ofstream ofl2(“temp1.txt”,ios::binary);
if(!ofl2)
cout<<”Error While Opening File”;
ifstream ifl4(“PersonalDetails.txt”,ios::binary);
if(!ifl4)
cout<<”Error While Opening File”;
ifl4.read((char*)&pob,sizeof(pob));
while(!ifl4.eof())
{
if(pob.givecode()==c)
{
clrscr();
cout<<”Please Enter the New details of the record”<<endl;
pob.p_input(c);
ofl2.write((char*)&pob,sizeof(pob));
cout<<”ntttModification Succesful!!!”;
ifl4.read((char*)&pob,sizeof(pob));
}
else
{
ofl2.write((char*)&pob,sizeof(pob));
ifl4.read((char*)&pob,sizeof(pob));
}
}
remove(“PersonalDetails.txt”);
rename(“temp1.txt”,”PersonalDetails.txt”);
ifl4.close();
ofl2.close();
getch();
}
void editt(int c)  //to edit travdetails
{
ofstream ofl2(“temp1.txt”,ios::binary);
if(!ofl2)
cout<<”Error While Opening File”;
ifstream ifl4(“TravelDetails.txt”,ios::binary);
if(!ifl4)
cout<<”Error While Opening File”;
ifl4.read((char*)&tob,sizeof(tob));
while(!ifl4.eof())
{
if(tob.gtcode()==c)
{
clrscr();
cout<<”Please Enter the New details of the record”<<endl;
tob.t_input(c);
ofl2.write((char*)&tob,sizeof(tob));
cout<<”ntttModification Succesful!!!”;
ifl4.read((char*)&tob,sizeof(tob));
}
else
{
ofl2.write((char*)&tob,sizeof(tob));
ifl4.read((char*)&tob,sizeof(tob));
}
}
remove(“TravelDetails.txt”);
rename(“temp1.txt”,”TravelDetails.txt”);
ifl4.close();
ofl2.close();
getch();
}
void deletion(int c)  //common delete func()
{
ofstream ofl2(“temp1.txt”,ios::binary);
if(!ofl2)
cout<<”Error While Opening File”;
ifstream ifl4(“PersonalDetails.txt”,ios::binary);
if(!ifl4)
cout<<”Error While Opening File”;
ifl4.read((char*)&pob,sizeof(pob));
while(!ifl4.eof())
{
if(pob.givecode()!=c)
{
ofl2.write((char*)&pob,sizeof(pob));
}
ifl4.read((char*)&pob,sizeof(pob));
}
remove(“PersonalDetails.txt”);
rename(“temp1.txt”,”PersonalDetails.txt”);
ofl2.close();
ifl4.close();
ofstream ofl3(“temp2.txt”,ios::binary);
if(!ofl3)
cout<<”nError While Opening File”;
ifstream ifl5(“TravelDetails.txt”,ios::binary);
if(!ifl5)
cout<<”nError While Opening File”;
ifl5.read((char*)&tob,sizeof(tob));
while(!ifl5.eof())
{
if(tob.gtcode()!=c)
{
ofl3.write((char*)&tob,sizeof(tob));
}
ifl5.read((char*)&tob,sizeof(tob));
}
ofl3.close();
ifl5.close();
remove(“TravelDetails.txt”);
rename(“temp1.txt”,”TravelDetails.txt”);
cout<<”nnttDeletion Completed!”;
getch();
}
void travdetails::compute()   //compution+bill generation
{
long int gttl=0,hr,dcst,dck,cabn,swpool=5000,gm=2000,spfts=7500,slon=6000,sp=20000,ttr=500;
switch(go_pt)
{
case 1:;
case 2:;
case 3:hr=30*24;
dcst=250000;
break;
case 4:;
case 5:;
case 6:hr=7*24;
dcst=75000;
break;
case 7:;
case 8:;
case 9:hr=24*24;
dcst=130000;
break;
case 10:;
case 11:;
case 12:hr=15*24;
dcst=100000;
break;
case 13:;
case 14:;
case 15:hr=12*24;
dcst=120000;
break;
}
switch(deck)
{
case 1:dck=7500;
break;
case 2:dck=5000;
break;
case 3:dck=1000;
}
switch(cabin)
{
case 1:cabn=5000;
break;
case 2:cabn=2000;
break;
}
clrscr();
cout<<”nntt:::::::::::::::::::::: BILL ::::::::::::::::::::::::::”;
cout<<”nnttBoarding point:tt “;
boardpt(bdg_pt);
cout<<”nnttDestination:tt “;
dest(go_pt);
cout<<”nnttDate of Departure: “;
cout<<day<<”/”<<month<<”/”<<year;
hr=hr/24;         //to calculate date of arrival
day=day+hr;
if(month==1||month==3||month==5||month==7||month==8||month==10||month==12)
{
if(day>31)
{
month=month+1;
day=day%31;
}
}
if(month==4||month==6||month==9||month==11)
{
if(day>30)
{
month=month+1;
day=day%30;
}
}
if(month==2)
{
if(day>28)
{
month=month+1;
day=day%28;
}
}
if(month==13)
{
month=1;
year++;
}
cout<<”nnttDate of Arrival: “;
cout<<day<<”/”<<month<<”/”<<year;
cout<<”nnttSubjectttCost(for 1)tNo of ppltTotal”;
cout<<”nnttTraveltt”<<dcst<<”tt   “<<num1<<”tt”<<num1*dcst;
gttl+=num1*dcst;
cout<<”nttDecktt”<<dck<<”tt   “<<num1<<”tt”<<dck*num1;
gttl+=dck*num1;
cout<<”nttCabintt”<<cabn<<”tt   “<<num1<<”tt”<<cabn*num1;
gttl+=cabn*num1;
if(pool==1)
{
cout<<”nttSwimming Poolt”<<swpool<<”tt   “<<num1<<”tt”<<swpool*num1;
gttl+=swpool*num1;
}
if(gym==1)
{
cout<<”nttGymtt”<<gm<<”tt   “<<num1<<”tt”<<gm*num1;
gttl+=gm*num1;
}
if(sports==1)
{
cout<<”nttSportstt”<<spfts<<”tt   “<<num1<<”tt”<<spfts*num1;
gttl+=spfts*num1;
}
if(salon==1)
{
cout<<”nttSalontt”<<slon<<”tt   “<<num1<<”tt”<<slon*num1;
gttl+=slon*num1;
}
if(spa==1)
{
cout<<”nttSpatt”<<sp<<”tt   “<<num1<<”tt”<<sp*num1;
gttl+=dcst*num1;
}
if(theatre==1)
{
cout<<”nttTheatrett”<<ttr<<”tt   “<<num1<<”tt”<<ttr*num1;
gttl+=ttr*num1;
}
cout<<”nnnttt  Grand Total:Rs “;
if(gttl>100000)     //to provide comma’s for grandtotal
{
cout<<gttl/100000<<”,”;
gttl=gttl%100000;
}
if(gttl>1000)
{
cout<<gttl/1000<<”,”;
gttl=gttl%1000;
}
cout<<gttl;
if(gttl<10)
cout<<”00″;
cout<<”  ”;
cout<<”nnt  ! All Travellers below the age of 5 have not been charged !  ”;
getch();
}
void main()
{
clrscr();
cout<<”nnnnn”;   //welcome screen
cout<<”                          **      :::::::  !!!!!!!!                       n”;
cout<<”                   _____  **      ::       !!    !!                _____  n”;
cout<<”                          **      ::       !!    !!                       n”;
cout<<”                          ******  :::::::  !!!!!!!!                       n”;
cout<<”nnnnn”;
cout<<”          ~    __  ~ __  ~ __                  n”;
cout<<”           |==|  |==|  |==|                 n”;
cout<<”         __|__|__|__|__|__|_                n”;
cout<<”      __|___________________|___            n”;
cout<<”       __|__[]__[]__[]__[]__[]__[]__|___         CRUISE DATABASE MANAGEMENTn”;
cout<<”      |……………………….o…/ n”;
cout<<”      \…………………………./ n”;
cout<<”~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~n”;
cout<<” ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ n”;
cout<<”  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~  ~n”;
cout<<”    ~    ~     ~    ~    ~    ~    ~    ~    ~  n”;
cout<<”     ~    ~      ~    ~     ~    ~    ~      ~n”;
ifstream fl(“INITIALL.txt”,ios::binary); //initialisation of code
if(!fl)
cout<<”nError”;
fl.read((char*)&code,sizeof(code));
fl.close();
int opt,opt1,opt2,opt3,opt4;
int acceptcode,flag;
getch();
clrscr();
do
{
clrscr();
cout<<”nntt¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬n”;
cout<<”tt  ….WELCOME TO THE CRUISE DATABASE SYSTEM…. n”;
cout<<”tt                                                 nnn”;
cout<<”tt                                                 n”;
cout<<”tt                    MAIN MENU                    n”;
cout<<”tt                                                 nn”;
cout<<”ntttPlease select a kind of user:”;
cout<<”nntttt1.New Usernntttt2.Existing Usernntttt3.Exit”;
cout<<”nntttt  “;
cin>>opt;
switch(opt)
{
case 1:do
{
clrscr();
cout<<”nnntttt    NEW USERn”;
cout<<”tttt    ********nn”;
cout<<”nntttChoose the type of details you want to enter:”;
cout<<”nntttt1.Personal Detailsnntttt2.Travel Detailsnntttt3.Backnntttt  “;
cin>>opt1;
switch(opt1)
{
case 1:code++;
pob.p_input(code);
ofstream ofl(“PersonalDetails.txt”,ios::binary|ios::app);
if(!ofl)
cout<<”nnttSorry.The File Cannot Be Opened For Writing”<<endl;
ofl.write((char*)&pob,sizeof(pob));
ofl.close();
break;
case 2:tob.t_input(code);
ofstream ofl1(“TravelDetails.txt”,ios::binary|ios::app);
if(!ofl1)
cout<<”nnttSorry.The File Cannot Be Opened For Writing”<<endl;
ofl1.write((char*)&tob,sizeof(tob));
ofl1.close();
clrscr();
cout<<”nnnn!!!!!Your Details Have Been Registered.Please Make A Note Of This Code: “<<code;
cout<<”nn* For modifications,Please visit ‘existing user’ section in the main screen”;
getch();
break;
}
}while(opt1!=3);
break;
case 2:clrscr();
cout<<”nnttt ***** EXISTING USER ***** nnttPlease Enter The Travel Code That Was Given To Younnttt  “;
cin>>acceptcode;
if(acceptcode>code)
{
cout<<”nNo such record has been created!”;
break;
}
family(acceptcode,flag);
cout<<endl<<endl<<”ttttCode no:”<<acceptcode;
getch();
if(flag==1)
{
do
{
clrscr();
cout<<”nnttt@@@@@@@@@ Information Centre @@@@@@@@@”;
cout<<”ntttt  ~~~~~~~~~~~~~~~~~”;
cout<<”nntPlease select the type of operation that you would like to perform:”;
cout<<”nnttt1.View Personal Detailsnnttt2.View Travel Detailsnnttt3.Edit Detailsnnttt4.Compute Billnnttt5.Backnnttt  “;
cin>>opt2;
switch(opt2)
{
case 1:ifstream ifl(“PersonalDetails.txt”,ios::binary);
if(!ifl)
cout<<”nError”;
ifl.read((char*)&pob,sizeof(pob));
while(!ifl.eof())
{
if(pob.givecode()==acceptcode)
{
break;
}
ifl.read((char*)&pob,sizeof(pob));
}
pob.p_output();
ifl.close();
break;
case 2:ifstream ifl1(“TravelDetails.txt”,ios::binary);
if(!ifl1)
cout<<”nError”;
ifl1.read((char*)&tob,sizeof(tob));
while(!ifl1.eof())
{
if(tob.gtcode()==acceptcode)
{
break;
}
ifl1.read((char*)&tob,sizeof(tob));
}
tob.t_output();
ifl1.close();
break;
case 3:do
{
clrscr();
cout<<”nnnt¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬  Edit Details  ¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬¬”;
cout<<”nnttPlease select from among the editing options:nn”;
cout<<”tttt1.Modifynntttt2.Deletenntttt3.Backnntttt  “;
cin>>opt3;
switch(opt3)
{
case 1:do
{
clrscr();
cout<<”nntt               Modificaton                n”;
cout<<”tt               ~~~~~~~~~~~”;
cout<<”nntChoose The Type Of Details You Want To Modify:nnttt1.Personal Detailsnnttt2.Travel Detailsnnttt3.Backnnttt  “;
cin>>opt4;
switch(opt4)
{
case 1:editp(acceptcode);
break;
case 2:editt(acceptcode);
break;
case 3:break;
}
}while(opt4!=3);
break;
case 2:deletion(acceptcode);
opt3=3;
opt2=5;
break;
case 3:break;
}
}while(opt3!=3);
break;
case 4:ifstream ifl3(“PersonalDetails.txt”,ios::binary);
if(!ifl3)
cout<<”nError”;
ifl3.read((char*)&pob,sizeof(pob));
while(!ifl3.eof())
{
if(pob.givecode()==acceptcode)
{
break;
}
ifl3.read((char*)&pob,sizeof(pob));
}
ifstream ifl2(“TravelDetails.txt”,ios::binary);
if(!ifl2)
cout<<”nError”;
ifl2.read((char*)&tob,sizeof(tob));
while(!ifl2.eof())
{
if(tob.gtcode()==acceptcode)
{
break;
}
ifl2.read((char*)&tob,sizeof(tob));
}
tob.accept(pob.give());
tob.compute();
ifl2.close();
break;
case 5:break;
}
}while(opt2!=5);
}
break;
case 3:ofstream fil(“INITIALL.txt”,ios::binary); //storing code value
if(!fil)
cout<<”nError”;
fil.write((char*)&code,sizeof(code));
fil.close();
getch();
exit(0);
}
getch();
}while(1); //infinite loop till exit selected
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Popular Posts

Labels

© Codepirate is powered by Blogger - Template designed by Stramaxon - Best SEO Template