// HOPE THE LAST TRY.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <dos.h>
#define PERSONALFLIGHT 1
#define EXECUTIVECLASS 2
#define ECONOMICALCLASS 3
#define EXIT 4
int _tmain(int argc, _TCHAR* argv[])
{
int seats[10] = {0};
int bookTiketForPersonalFlight;
int bookTiketForExecutiveClass;
int bookTiketForEconomicalClass;
return 0;
}
void main()
{
int choice;
int seatNo;
while(1)
{
printf("SELAMAT DATANG KE UTHM AIRLINES SEAT BOOKING SYSTEM.\n");
printf("\nPlease type 1 for PERSONAL FLIGHT");
printf("\nPlease type 2 for EXECUTIVE CLASS");
printf("\nPlease type 3 for ECONOMICAL CLASS");
printf("\nPlease type 4 to EXIT");
printf("\n\nEnter your choice : ",choice);
scanf_s("%d",&choice);
printf("%d",choice);
switch(choice)
{
case 1:
seatNo= bookTiketForPersonalFlight;
if(-1 == seatNo)
{
printf("\n\aAll tickets for PersonalFlight is full,\n Do you want another class[1 for ExecutiveClass, 2 for EconomicalClass,any other key for no]");
scanf_s("%d",&choice);
if(1 == choice)
{
seatNo = bookTiketForExecutiveClass;
if(-1 == seatNo)
{
printf("\n\a\a\aBooking is over All tickets sold! press any key...");
break;
}
}
else if(2==choice)
{
seatNo = bookTiketForEconomicalClass;
if(-1 == seatNo)
{
printf("\n\a\a\aBooking is over All tickets sold! press any key...");
break;
}
}
else
{
printf("\n\aSorry try after 3 hour..! press any key...");
break;
}
}
printf("\n\nYour Seat is confirm, Seat Number = %d \n\n\n! press any key...",seatNo);
break;
case 2:
seatNo = bookTiketForExecutiveClass;
if(-1 == seatNo)
{
printf("\n\aAll tickets for ExecutiveClass area is full,\n Do you want another class[1 for PersonalFlight,2 for EconomicalClass,any other key for no]");
scanf_s("%d",&choice);
if(1 == choice)
{
seatNo = bookTiketForPersonalFlight;
if(-1 == seatNo)
{
printf("\nBooking is over All tickets sold! press any key...");
break;
}
}
else if(2 == choice)
{
seatNo = bookTiketForEconomicalClass;
if(-1 == seatNo)
{
printf("\nBooking is over All tickets sold! press any key...");
break;
}
}
else
{
printf("\n\aSorry try after 3 hour..! press any key...");
break;
}
}
printf("\n\nYour Seat is confirm, Seat Number = %d \n\n\n! press any key...",seatNo);
break;
case 3:
seatNo = bookTiketForEconomicalClass;
if(-1 == seatNo)
{
printf("\n\aAll tickets for EconomicalClass area is full,\n Do you want another class[1 for PersonalFlight,2 for EcecutiveClass,any other key for no]");
scanf_s("%d",&choice);
if(1 == choice)
{
seatNo = bookTiketForPesonalFlight;
if(-1 == seatNo)
{
printf("\nBooking is over All tickets sold! press any key...");
break;
}
}
else if(2 == choice)
{
seatNo = bookTiketForExecutiveClass;
if(-1 == seatNo)
{
printf("\nBooking is over All tickets sold! press any key...");
break;
}
}
else
{
printf("\n\aSorry try after 3 hour..! press any key...");
break;
}
}
printf("\n\nYour Seat is confirm, Seat Number = %d \n\n\n! press any key...",seatNo);
break;
case 4:
printf("\n\nGood Bye...!, press any key... ");
exit(1);
break;
default:
printf("\n\n\n\aWrong Input Please type 1,2 or 3!, press any key... ");
break;
}
}
int bookTiketForPersonalFlight
{
int i;
for(i=5;i<10;i++)
{
if(0 == seats[i])
{
seats[i] = 1;
return i+1;
}
}
return -1;
}
int bookTiketForExecutiveClass
{
int i;
for(i=5;i<10;i++)
{
if(0 == seats[i])
{
seats[i] = 1;
return i+1;
}
}
return -1;
}
int bookTiketForEconomyClass
{
int i;
for(i=0;i<5;i++)
{
if(0 == seats[i])
{
seats[i] = 1;
return i+1;
}
}
return -1;
}
}
↧
how to declare int in my coding
↧