Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   help me urgent (http://www.go4expert.com/forums/help-me-urgent-t15141/)

dky8810 15Nov2008 10:10

help me urgent
 
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

xpi0t0s 15Nov2008 19:10

Re: help me urgent
 
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?

dky8810 15Nov2008 19:21

Re: help me urgent
 
Quote:

Originally Posted by xpi0t0s (Post 38978)
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?

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);*/
}

here here it can no run???
"if(cust[sizeR][sizeC] != 0)"
line60 till 70

shabbir 15Nov2008 19:23

Re: help me urgent
 
Use code block when you use Code in Posts and also write the code which is readable and well tabbed.

xpi0t0s 16Nov2008 00:00

Re: help me urgent
 
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];

If you have typedef struct { ... } customer;, that defines customer as struct { ... }, and you don't need to use "struct customer".

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?

dky8810 16Nov2008 03:45

Re: help me urgent
 
Quote:

Originally Posted by xpi0t0s (Post 38986)
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];

If you have typedef struct { ... } customer;, that defines customer as struct { ... }, and you don't need to use "struct customer".

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?

i have cancel the keyword"struct",i use typedef format.the problem in this line show by my compile is :(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 ??

xpi0t0s 16Nov2008 03:58

Re: help me urgent
 
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.

dky8810 16Nov2008 04:14

Re: help me urgent
 
Quote:

Originally Posted by xpi0t0s (Post 38989)
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.

i done this
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).

xpi0t0s 16Nov2008 04:28

Re: help me urgent
 
What type is cust[sizeR][sizeC]? Is it an integer?

dky8810 16Nov2008 04:40

Re: help me urgent
 
Quote:

Originally Posted by xpi0t0s (Post 38992)
What type is cust[sizeR][sizeC]? Is it an integer?

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!");
}
        }

in this part it keep looping how to stop it??
if(flag==0)
printf("Please enter your name\n",cust[sizeR][sizeC].name);


All times are GMT +5.5. The time now is 21:04.