question:
The airline company, KL AIRLINE, has engaged your teanm to develop a new Airline Ticket Reservation System....airplane wiyh the occupancy of "20 passengers".
!.display the KL "Airline Reservation Menu" for the user to select from 2 main options which are to do "Booking" and "display seat layout & occupancy".thr is one last option -to "exit" from the system after displaying an appropriate farewell message.
2.Booking
-ask user for yhe number of seat required
-Generete the Booking ID(if enough seats are available)
-for each seat required,
*ask for the passenger name,
*assign the booking ID to the seat, and
*display the ticket in following format:
-------------------------------------------------------------------------------------
| --KL airline booking tikcket---- |
| booking ID:100 Flight No.:AK65 |
| Passenger:XXXXXXXXX Date :25-12-2008 |
| Time :23:45 |
| Gate :G9 |
| seat No :3B |
---------------------------------------------------------------------------------------
note:-( Flight No,Date,Time,Gate )will be initizalized either during compile-time or run time.the details are to be stored in a "Struture variable"
-hv all the necessary "validation" in place, including useful messages, "not enough seat available"
- must use a Two Dimensional Array to store the seat information(the booking ID or a Zero value).
3.display seat layout & Occupancy
sample:
A B C D E
|--------------------------------------------|
1 |101 | 101 | 101 |102 | 103 |
|-------------------------------------------|
2 |103 |104 |104 |104 |0 |
|-------------------------------------------|
| Aisle |
|-------------------------------------------|
3 | 0 | 0 | 0 | 0 | 0 |
|-------------------------------------------|
4 | 0 | 0 | 0 | 0 |0 |
|-------------------------------------------|
******required to use :array,structure,Function***********
T.T pls help hv to submit:19 nov 2008
|
Mentor
|
![]() |
| 15Nov2008,19:10 | #2 |
|
We can't help you if we don't know what the problem is. In what way are you stuck? Is there some specific code you're struggling with, in the sense that what you've written doesn't do what you want it to?
|
|
Go4Expert Member
|
|
| 15Nov2008,19:21 | #3 |
|
Quote:
Originally Posted by xpi0t0s Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define sizeR 4
#define sizeC 5
void menu(void);
void Booking(void);
void getinf(void);
void Display(void);
typedef struct{
int id;
char flightNo[40];
char date[20];
char time;
char gate;
char seatNo;
}customer;
struct customer cust[sizeR][sizeC];
void menu(void)
{
int choice;
printf("\t\t********TARC Airlene Reservation Menu*********\n");
printf("\t\t1) Booking\n");
printf("\t\t2) Seat Layout & Occupancy\n");
printf("\t\t3) Exit\n");
printf("\t\t\tYour choice : ");
scanf("%d",&choice);
switch(choice){
case 1:
Booking();
break;
case 2:
Display();
break;
default:
printf("End the program");
break;
}
}
void main()
{
menu();
}
void Booking(void)
{
customer cust[sizeR][sizeC];
int i;
int j;
int row;
int col;
printf("How many seat are you required:\n");
scanf("%d",&i);
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(cust[sizeR][sizeC] != 0){
int fp[4]={0},i,f;
printf("hhh\n\n");
for(i=0;i<10;i++){
f=cust[sizeR][sizeC];
fp[f]++;
}
for(i=0;i<4;i++){
printf("%d\n\n",i,fp[i]);
}
}
}
}
else
printf("Not enough seats available!The flight is fully booked!");
}
void Display(void)
{
}
void getinf(void)
{
/* int i;
printf("Please enter your name:");
scanf("%[^\n]",cust[sizeR][sizeL].name);*/
}
"if(cust[sizeR][sizeC] != 0)" line60 till 70 Last edited by shabbir; 15Nov2008 at 19:22.. Reason: Code block |
|
Go4Expert Founder
|
![]() |
| 15Nov2008,19:23 | #4 |
|
Use code block when you use Code in Posts and also write the code which is readable and well tabbed.
|
|
Mentor
|
![]() |
| 16Nov2008,00:00 | #5 |
|
Are you sure it won't run? As in: it compiles OK but there is a runtime problem?
For me it wouldn't even compile, although it's possible we're using different compilers (I'm using Visual Studio 2005). The first error I got was the redefinition of customer, so I changed the definition to: Code:
struct customer {
int id;
char flightNo[40];
char date[20];
char time;
char gate;
char seatNo;
};
struct customer cust[sizeR][sizeC];
Then I got a compile error on "if(cust[sizeR][sizeC] != 0)", which I presume is what you're trying to say. Why do you think there might be a problem with this line? What type is cust[sizeR][sizeC]? Do you think it's possible to compare one of those directly with an integer? |
|
Go4Expert Member
|
|
| 16Nov2008,03:45 | #6 |
|
Quote:
Originally Posted by xpi0t0s binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator).cust[sizeR][sizeC]is array of structure.what code i need to use for know array element is empty ??
|
|
Mentor
|
![]() |
| 16Nov2008,03:58 | #7 |
|
You could initialise it to a certain value that indicates that a particular entry is empty. For example if all customer IDs are greater than zero, you could use 0 as the ID for an empty slot. Or you could have an explicit isEmpty variable, which would make the code easier to understand. On program startup you would need to initialise all isEmpty's to TRUE, then as each is allocated to a customer you could set it to FALSE. Then all you need to do is test the value of cust[][].isEmpty.
|
|
Go4Expert Member
|
|
| 16Nov2008,04:14 | #8 |
|
Quote:
Originally Posted by xpi0t0s int ID[4][5]={ {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }; if(cust[sizeR][sizeC] != 0) but the problem in line 70 show by my compile is binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator). |
|
Mentor
|
![]() |
| 16Nov2008,04:28 | #9 |
|
What type is cust[sizeR][sizeC]? Is it an integer?
|
|
Go4Expert Member
|
|
| 16Nov2008,04:40 | #10 |
|
it is array of structure (two dimensional array)it contain string and integer!!
i hv change the code : Code:
void Booking(void)
{
int ID[4][5]={
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0},
{0,0,0,0,0}
};
customer cust[sizeR][sizeC];
int i;
int row;
int col;
int flag=0;
printf("How many seat are you required:\n");
scanf("%d",&i);
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(0==ID[4][5]){
flag=1;
break;
}
}
if(flag==0)
printf("Please enter your name\n",cust[sizeR][sizeC].name);
else
printf("Not enough seats available!The flight is fully booked!");
}
}
if(flag==0) printf("Please enter your name\n",cust[sizeR][sizeC].name); Last edited by shabbir; 16Nov2008 at 10:23.. Reason: Code block |




binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator).cust[sizeR][sizeC]is array of structure.what code i need to use for know array element is empty ??