HI and hello,
This is sundar...i'm posting a project that i've done 'Airline Reservation System'...
Pls go thru it and let me faults if any...and also how to enhance this code....
(pls find attachment)
sundar.mn 0 Newbie Poster
#include <time.h>
#include <graphics.h>
#include <stdio.h>
#include <iostream.h>
#include <conio.h>
#include <process.h>
#include <stdio.h>
void ticketch(int);
struct get_name
{
char name[21];
};
struct get_data
{
get_name name;
char sex;
int age;
};
get_data data[100];
void getdata(int n)
{
int x=n;
for(int i=0;i<x;++i)
{
cout<<"\nPLEASE ENTER NAME(S) :"<<endl;
cout<<i+1<<".";
gets(data[i].name.name);
s:
cout<<"\nPLEASE ENTER SEX(M/F): ";
cin>>data[i].sex;
cout<<"\nPLEASE ENTER AGE : ";
cin>>data[i].age;
}
}
void putdata(int n);
void putdata(int n)
{
int x=n;
for(int i=0;i<x;++i)
{
cout<<endl;
cout<<i+1<<"."<<"NAME : ";
puts(data[i].name.name);
cout<<" SEX : ";
cout<<data[i].sex;
cout<<"\n AGE : ";
cout<<data[i].age;
}
}
void display1(void)
{
textmode(BW40);
cout<<"\n\n\n\n\n\n\n\n\t VSV AIRLINES \t\t\t\t\t\t";
cout<<"\n (AIRLINE RESERVSTION DATA BASE)";
cout<<"\n\n\n\n\n\n\n\n\nProject By: "<<"\nV.Vidyasagar"<<"\nJ.Vittaldeep";
cout<<"\nM.N.Sundar";
cout<<"\nCLASS:XII";
cin.get();
}
void timex(void)
{
time_t t;
time(&t);
cprintf("\n\r%s", ctime(&t));
}
void display2(void)
{
textbackground(BLACK);
textcolor(WHITE);
textmode(BW80);
textbackground(BLACK);
textcolor(WHITE);
cout<<"\n\t\t\t\t";
cprintf("VSV AIRLINES");
timex();
cprintf("\n\rWelcome Dear Guest,");
}
void display3(void)
{
textcolor(WHITE);
textbackground(BLACK);
cprintf("\n\rYOU WANT TO TRAVEL");
textcolor(RED);
textbackground(DARKGRAY);
cout<<"\t\t\t ";
cprintf("FLIGHTS OFFERED");
textcolor(WHITE);
textbackground(BLACK);
cprintf("\n\r\rFROM:\r\n");
cprintf("\rBANGALORE");
textcolor(GREEN + BLINK);
textbackground(BLACK);
cout<<"\t\t\t\t\t ";
cprintf("BOEING-747");
cout<<"\n\t\t\t\t\t\t";
cprintf("AIRBUS-320");
cout<<"\n\t\t\t\t\t\t";
cprintf("AIRBUS-380");
textcolor(WHITE);
textbackground(BLACK);
cprintf("\n\rTo :");
textcolor(LIGHTMAGENTA+BLINK);
textbackground(BLACK);
cprintf("\n\r1.CHENNAI");
textcolor(BROWN+BLINK);
cprintf("\n\r2.THIRUVANANTHAPURAM");
textcolor(WHITE);
textbackground(BLACK);
cprintf("\n\r========================================================================");
}
char x;
int n;
char name[31];
void dispchennai(void)
{
int ch1;
textcolor(RED);
cout<<"\n ";
cout<<"\n SN F.CODE TIMING DAY FARE ";
cout<<"\n (ARR)(DEP) ";
cout<<"\n 1 1011 8:30 9:50 ALL(EXCEPT SUN) Rs.750+2656tax=Rs.3405/- ";
cout<<"\n 2 2987 11:45 13:50 ALL Rs.650+2309tax=Rs.2951/- ";
cout<<"\n 3 3465 14:00 15:20 ONLY SUNDAY Rs.575+2036tax=Rs.2611/- ";
cout<<"\n ";
cout<<"\n\n\rPLEASE ENTER A CHOICE(1/2/3): ";
cin>>ch1;
cout<<"\nWOULD YOU LIKE TO CONFIRM IT(y/n): ";
cin>>x;
if(x=='y' || x=='Y')
{
switch(ch1)
{
case 1:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*3405<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
case 2:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*2951<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
case 3:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*2611<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
default:
cout<<"\nSorry wrong choice.Terminating.";
getch();
exit(0);
}
}
else
cout<<"\nSorry Terminating.";
getch();
exit(0);
}
void disp_trivandrum(void)
{
int ch2;
textcolor(RED);
cout<<"\n ";
cout<<"\n SN F.CODE TIMING DAY FARE ";
cout<<"\n (ARR)(DEP) ";
cout<<"\n 1 9241 7:20 8:45 ALL(EXCEPT SUN) Rs.725+2557tax=Rs.3292/- ";
cout<<"\n 2 8001 10:05 11:30 ALL Rs.625+2213tax=Rs.2838/- ";
cout<<"\n 3 6237 13:00 14:25 ONLY SUNDAY Rs.550+1947tax=Rs.2697/- ";
cout<<"\n ";
cout<<"\n\n\rPLEASE ENTER A CHOICE(1/2/3): ";
cin>>ch2;
cout<<"\nWOULD YOU LIKE TO CONFIRM IT(y/n): ";
cin>>x;
if(x=='y' || x=='Y')
{
switch(ch2)
{
case 1:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*3292<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
case 2:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*2838<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
case 3:
cout<<"\nPLEASE ENTER THE NO. OF PERSONS"<<"\nTRAVELLING\t\t\t :";
cin>>n;
getdata(n);
cout<<"\nTOTAL COST OF THE TRIP:Rs. "<<n*2467<<"/-";
cout<<"\n(Press Enter to recieve your ticket)";
getch();
ticketch(n);
getch();
break;
default:
cout<<"\nSorry wrong choice.Terminating.";
getch();
exit(0);
}
}
else
cout<<"\nSorry Terminating.";
getch();
exit(0);
}
void ticketch(int n)
{
int x=n;
clrscr();
cout<<"\nYOUR TICKET"<<endl;
putdata(x);
}
void display4(int ch)
{
clrscr();
switch(ch)
{
case 1:
dispchennai();
break;
case 2:
disp_trivandrum();
break;
default:
cout<<"Invalid Choice.Sorry Terminating.";
getch();
exit(0);
}
}
int main()
{
clrscr();
int ch;
display1();
while(1)
{
display2();
display3();
textcolor(YELLOW);
cprintf("\n\n\n\n\rPLEASE ENTER CHOICE(1/2): ");
cin>>ch;
display4(ch);
textcolor(WHITE);
textbackground(BLACK);
clrscr();
char cont='y';
cout<<"\n\n";
cprintf("Do you want to continue Booking Tickets??(Y/N)");
cin>>cont;
if(cont=='n' || cont=='N') break;
clrscr();
}
return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
1) gets() -- never use it. Read this for explaination of why.
lines 26-27: There is no need for variable x. Just use the parameter variable n.
line 41: >>void putdata(int n); Delete that line because its not necessary to prototype a function before actually writing the code for it. Most programmers will have all function progotypes at the very beginnning of the program, after the #include <blabla>
statements.
line 44: same as previous comment about 26-27.
No comments about the rest of your program because I don't use ancient Turbo C++.
sundar.mn 0 Newbie Poster
thank u...i'll surely make these changes...
if u dont mind i've few problems that i am unable to solve....if u dont mind i'll post them,so that u can help me sort them out
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
thank u...i'll surely make these changes...
if u dont mind i've few problems that i am unable to solve....if u dont mind i'll post them,so that u can help me sort them out
Just don't expect us to write the code for you -- we will gladly help YOU do that though :)
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.