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
What do you have so far? We won't do your homework for you, but we can help guide you to the solution.
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; 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);*/ }
Last edited by dky8810; 11-15-2008 at 02:28 PM. Reason: add code tags (the # button)
OK, now, what questions do you have to move forward? I notice that you have nothing in your display function, and your menu only lets you pick once.
if(cust[sizeR][sizeC] != 0)
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 how many array element is empty ??
line 60-70
Last edited by dky8810; 11-15-2008 at 02:28 PM.
i hv change the code :in this part it keep looping how to stop it??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 WingedPanther; 11-15-2008 at 05:33 PM. Reason: add code tags (the # button)
1) please use code tags when posting code.
2) you cannot compare a struct with 0. You have to compare an item in the struct with 0.
3) the break only breaks you out of the inner for loop, not the outer for loop.
this is "array" not struct ,so i dont understand why saying that compere a struct with 0?Code:int ID[4][5]={ {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} };
the break .....can give an exemple?
help help!!
i no ideal for next part
question:
now is this part make me blur:what i need to write in <if>the code that can let me check still got how many empty place in my cust array??
Code:
can?Code:for(row=0;row<sizeR;row++){ for(col=0;col<sizeC;col++){ if(0==ID[row][col]){ for(j=0;j<i;j++){ printf("Enter your name"); scanf("%[\n]c",cust[sizeR][sizeC].name); } else{ printf("Not enough seats available!The flight is fully booked!");
Last edited by WingedPanther; 11-17-2008 at 09:03 AM. Reason: triple post
1) You are never updating array ID to non-zero values.
2) It seems like you need to sit down and create a flowchart/pseudocode of your logic. I don't have a clear sense that you have thought out what you want to do. Instead, you seem to be changing things and getting things worse, rather than better.
why it keep looping?which line i wrong????Code:void Booking(void) { strcpy(cust[sizeR][sizeC].flightNo,"AK65"); strcpy(cust[sizeR][sizeC].date,"25-12-2008"); strcpy(cust[sizeR][sizeC].time,"23:45"); strcpy(cust[sizeR][sizeC].gate,"G9"); int ID[4][5]={ {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0}, {0,0,0,0,0} }; int con; int id; int i; int j; int row; int col; int flag=0; printf("How many seat are you required:\n"); scanf("%d",&i); int available_seats = 0; for(row=0; row<sizeR; row++){ for(col=0; col<sizeC; col++){ if(cust[sizeR][sizeC].id == 0){ available_seats++; } } } if(available_seats >= i){ for(j=0;j<i;j++){ printf("\t\t\t--- KL Airline Booking Ticket ---\n"); cust[sizeR][sizeC].id=id; id++; printf("\t\t\tBooking ID\t:%d",&cust[sizeR][sizeC].id); printf("\t\t\tFlight No.:"); scanf("%s",cust[sizeR][sizeC].flightNo); fflush(stdin); printf("\t\t\tPassenger:"); scanf("%[\n]s",cust[sizeR][sizeC].name); fflush(stdin); printf("\t\t\tDate:"); scanf("%s",cust[sizeR][sizeC].date); fflush(stdin); printf("\t\t\tTime:"); scanf("%s",cust[sizeR][sizeC].time); fflush(stdin); printf("\t\t\tGate:"); scanf("%s",cust[sizeR][sizeC].gate); fflush(stdin); printf("\t\t\tSeat No:"); scanf("%c",&cust[sizeR][sizeC].seatNo); fflush(stdin); i++; system("pause"); system("cls"); /* printf("Want Countinue? press 1"); scanf("%d",&con); if(con==1) { system("cls"); Booking(); } else { system("cls"); menu(); }*/ } } else{ printf("Not enough seats available!"); }
Last edited by WingedPanther; 11-17-2008 at 02:12 PM. Reason: fix formatting to be readable
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks