Sunteți pe pagina 1din 7

#include

#include
#include
#include

<stdio.h>
<stdlib.h>
<string.h>
<conio.h>

void booking(int *b1,int b2, int *b3);


void cancel(int *c1,int *c2, int c3);
/* run this program using the console pauser or add your own getch, system("paus
e") or input loop */
//personalinformation
struct info
{
char name[50];
int age;
int cnum;
char address[75];
};
int main()
{
int a[5], t[5], p[5], bt[5]={0,0,0,0,0}, yn=1, fn, ts=0, tcm, i, b, c=0,
compa, compb, compc, tc, x=0, y=0, z;
char pca[50]="AUTOUP", pcb[50]="50ME", pcc[50]="FREE", pcd[50]="50ME",
pce[50]="TAXFREE", pc[50];
float tp;
a[0]=54; t[0]=0;
a[1]=3; t[1]=0;
a[2]=123; t[2]=0;
a[3]=68; t[3]=0;
a[4]=76; t[4]=0;
struct info m;
char ch;
printf("\t\t\t\t\t\tAIR PHILIPPINES\n\n");
printf("\n\nName: ");
gets(m.name);
printf("Age: ");
scanf("%d", &m.age);
while((ch = getchar()) != '\n' && ch != EOF) { }
printf("Address: ");
gets(m.address);
printf("Contact Number: ");
scanf("%d", &m.cnum);
while(yn==1)
{
printf("\n");
printf("Flight No.\tDeparting\tArriving\t Seating Capacity\t\tAvailable
Seats\t\t Price\n");
printf("\n1\t\tManila\t\tBoracay\t\t\t150\t\t\t%d\t\t\t 13, 350\n",a[0]
);
printf("\n2\t\tManila\t\tTokyo\t\t\t150\t\t\t%d\t\t\t 21, 500\n",a[1]);
printf("\n3\t\tManila\t\tSeoul\t\t\t150\t\t\t%d\t\t\t 29, 000\n",a[2]);
printf("\n4\t\tManila\t\tParis\t\t\t150\t\t\t%d\t\t\t 41, 800\n",a[3]);
printf("\n5\t\tManila\t\tSydney\t\t\t150\t\t\t%d\t\t\t 41, 400\n",a[4])

;
printf("\n\n");
printf("\t\t [NOTE: You can only book a maximum of 10 tickets per transact
ion.]");
printf("\n");
printf("\t\t\t\t **ALL PRICES ARE IN PHILIPPINE PESO**\n");
printf("\n");
nstart:
while(ts<=10)
{
printf("Input flight number: ");
scanf("%d", &fn);
while((fn<=0)||(fn>5))
{
printf("INVALID FLIGHT NUMBER\n");
goto nstart;
}
printf("\nNumber of tickets: ");
scanf("%d",&b);
if (b>10)
{
printf("Only a maximum of 10 tickets per transaction. [BOOKING CANCELLED
]\n");
goto nstart;
}
else
{
switch (fn)
{
case 1: booking(&bt[0],b,&ts);
break;
case 2: booking(&bt[1],b,&ts);
break;
case 3: booking(&bt[2],b,&ts);
break;
case 4: booking(&bt[3],b,&ts);
break;
case 5: booking(&bt[4],b,&ts);
break;
}
i=fn-1;
if(ts>10)
{
//overbook
cancel(&ts,&bt[i],b);
printf("[OVERBOOKED. BOOKING CANCELLED]");
printf("Book again? Press [1]Yes [2]No ");
scanf("%d", &yn);
yn1a:
if(yn==1)
{
goto nstart;
}
else if(yn==2)
{
goto end;
}

else
{
printf("[INVALID NUMBER]\n");
goto yn1a;
}
//overbook
goto nstart;
}
else if(b>a[i])
{
//noseats
cancel(&ts,&bt[i],b);
printf("[NO AVAILABLE SEATS. BOOKING CAN
CELLED]\n");
goto nstart;
//noseats
}
else
{
//book
printf("[BOOKING SUCCESSFUL]\n\n");
a[i]=a[i]-b;
tca:
printf("Travel Class: [1]First Class [2]
Business Class [3]Economy Class ");
scanf("%d", &tc);
while((tc<=0)||(tc>3))
{
printf("INVALID NUMBER\n");
goto tca;
}
//classhandling
if(tc==1)
{
x=1;
}
else if(tc==2)
{
y=1;
}
//classhandling
printf("\nBook again? Press [1]Yes [2]No
");
scanf("%d", &yn);
yn1:
if(yn==1)
{
goto nstart;
}
else if(yn==2)
{
goto end;
}
else
{
printf("[INVALID NUMBER]");
goto yn1;
}

//book
goto nstart;
}
}
}
end:
p[0]=13350*bt[0];
p[1]=21500*bt[1];
p[2]=29000*bt[2];
p[3]=41800*bt[3];
p[4]=41400*bt[4];
tp=p[0]+p[1]+p[2]+p[3]+p[4];
printf("\n\n\t\t\t\t\t
**CUSTOMER INFORMATION**\n");
printf("\t\tName: %s\n", m.name);
printf("\t\tAge: %d\n", m.age);
printf("\t\tAddress: %s\n", m.address);
printf("\t\tContact Number: %d\n", m.cnum);
//travelmember
again:
printf("\n\t\tARE YOU A FREQUENT TRAVEL CLUB MEMBER? Press [1]Yes [2]No
");
scanf("%d", &tcm);
//promo
pc:
if(tcm==1)
{
while(c<=3)
{
printf("\n\n\t\tENTER A TRAVEL CLUB MEMBER PROMO CODE: "
);
scanf("%s", &pc);
compa=strcmp(pc, pca);
if(compa==0)
{
printf("\t\tCODE AVAILED: FREE SEAT UPGRADE");
if((x==1)&&(y==1))
{
tcb:
printf("\n\t\tWhich seat would you like
to upgrade? [1]First [2]Business ");
scanf("%d", &z);
while((z<=0)||(z>2))
{
printf("\t\tINVALID NUMBER\n");
goto tcb;
}
if(z==1)
{
printf("\n\t\t1 [FIRST CLASS] se
at upgraded to [BUSINESS CLASS] seat");
}
else
{

printf("\n\t\t1 [BUSINESS CLASS]


seat upgraded to [ECONOMY CLASS] seat");
}
}
else if((x==1)&&(y==0))
{
printf("\n\n\t\t1 [FIRST CLASS] seat upg
raded to [BUSINESS CLASS] seat");
}
else if((x==0)&&(y==1))
{
printf("\n\n\t\t1 [BUSINESS CLASS] seat
upgraded to [ECONOMY CLASS] seat");
}
else
{
printf("\n\t\tNO SEAT CAN BE UPGRADED [Y
ou may enter another promo code]\n");
goto pc;
}
break;
}
else
{
compb=strcmp(pc, pcb);
if(compb==0)
{
printf("\t\tPROMO CODE AVAILED: 50 PERCE
NT DISCOUNT");
tp=tp/2;
break;
}
else
{
compc=strcmp(pc, pcc);
if(compc==0)
{
printf("\t\tPROMO CODE AVAILED:
100 PERCENT DISCOUNT");
tp=0;
break;
}
else
{
c++;
}
}
}
}
}
else if(tcm==2)
{
while(c<=3)
{
printf("\n\n\t\tENTER A NON-TRAVEL CLUB MEMBER PROMO COD
E: ");
scanf("%s", &pc);
compa=strcmp(pc, pcd);

if(compa==0)
{
printf("\t\tPROMO CODE AVAILED: Php500 OFF");
tp=tp-500;
break;
}
else
{
compb=strcmp(pc, pce);
if(compb==0)
{
printf("\t\tPROMO CODE AVAILED: 10 PERCE
NT DISCOUNT");
tp=tp-0.10*tp;
break;
}
else
{
c++;
}
}
}
}
else
{
printf("INVALID NUMBER!");
goto again;
}
printf("\n\n\t\t\t\t\t**SUMMARY OF YOUR TRANSACTION**\n"
);
printf("\n\t\tFlight No.\tNumber of Tickets Booked\t Rem
aining Seats\tPrice\n");
printf("\n\t\t 1\t\t\t %d\t\t\t\t%d\t\t%d", bt[0], a[0
], p[0]);
printf("\n\t\t 2\t\t\t %d\t\t\t\t%d\t\t%d", bt[1], a[1
], p[1]);
printf("\n\t\t 3\t\t\t %d\t\t\t\t%d\t\t%d", bt[2], a[2
], p[2]);
printf("\n\t\t 4\t\t\t %d\t\t\t\t%d\t\t%d", bt[3], a[3
], p[3]);
printf("\n\t\t 5\t\t\t %d\t\t\t\t%d\t\t%d", bt[4], a[4
], p[4]);
printf("\n\n\t\tTOTAL PRICE: %0.2f Php\n", tp);
printf("\t\tTOTAL NUMBER OF TICKETS: %d\n", ts);
yn6:
printf("\n\t\tWould you like to make another transaction? Press
[1]Yes [2]No ");
scanf("%d", &yn);
ts=0;
x=0;
y=0;
for (i=0;i<=4;i++)
{
bt[i]=0;
p[i]=0;
}
}

system("PAUSE");
return 0;
}
void booking(int *b1,int b2, int *b3)
{
*b1=*b1+b2;
*b3=*b3+b2;
}
void cancel(int *c1,int *c2, int c3)
{
*c2=*c2-c3;
*c1=*c1-c3;
}

S-ar putea să vă placă și