Documente Academic
Documente Profesional
Documente Cultură
#include
#include
#include
<stdio.h>
<stdlib.h>
<string.h>
<conio.h>
;
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
{
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;
}