-
November 14th, 2008, 11:54 PM
#1
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
-
November 15th, 2008, 01:04 AM
#2
Re: help me urgent
No, not gonna do your homework for you. Besides, airline booking is annoying enough in reality.
-
November 15th, 2008, 01:13 AM
#3
Re: help me urgent
help me!!!i dont know how to do the looping to check that array have element or not!!? help
-
November 15th, 2008, 01:16 AM
#4
Re: help me urgent
Originally Posted by Lindley
No, not gonna do your homework for you. Besides, airline booking is annoying enough in reality.
pls pls tech me i rely try hard ald!!!
-
November 15th, 2008, 07:59 AM
#5
Re: help me urgent
This is why nobody is replying.
-
November 15th, 2008, 08:58 AM
#6
Re: help me urgent
Originally Posted by Skizmo
This is why nobody is replying.
#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
-
November 15th, 2008, 10:12 AM
#7
Re: help me urgent
Originally Posted by dky
help me!!!i dont know how to do the looping to check that array have element or not!!? help
You are using the wrong indexes in the if statement. Also, you cannot compare a customer struct to 0: You must check one of its fields specifically to determine if the seat is empty. Usually you would use "id" for this, with an id of -1 indicating an empty seat. (You'll have to initialize it that way at program start.)
Code:
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(cust[row][col] != 0){
//stuff here
}
}
}
Incidentally, you are doing:
Code:
scanf("%d",&i);
but then I don't see you using that value anywhere. In fact, you're declaring another i within the if statement, so (within that scope at least) it will be impossible to use this value, as the variable will be shadowed. Probably the easiest way to use this information is to maintain a count of the number of available seats, and immediately check against that after reading this in. Don't forget to decrement it when assigning seats!
Last edited by Lindley; November 15th, 2008 at 10:20 AM.
-
November 15th, 2008, 05:34 PM
#8
Re: help me urgent
Originally Posted by Lindley
You are using the wrong indexes in the if statement. Also, you cannot compare a customer struct to 0: You must check one of its fields specifically to determine if the seat is empty. Usually you would use "id" for this, with an id of -1 indicating an empty seat. (You'll have to initialize it that way at program start.)
Code:
for(row=0;row<sizeR;row++){
for(col=0;col<sizeC;col++){
if(cust[row][col] != 0){
//stuff here
}
}
}
Incidentally, you are doing:
Code:
scanf("%d",&i);
but then I don't see you using that value anywhere. In fact, you're declaring another i within the if statement, so (within that scope at least) it will be impossible to use this value, as the variable will be shadowed. Probably the easiest way to use this information is to maintain a count of the number of available seats, and immediately check against that after reading this in. Don't forget to decrement it when assigning seats!
if(cust[row][col] != 0)
show by my compile ( binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator)
-
November 15th, 2008, 06:19 PM
#9
Re: help me urgent
i hv change the 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);
-
November 15th, 2008, 06:21 PM
#10
Re: help me urgent
ANOTHER reason people (injcluding myself) is your refusal to use proper code tags....
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
November 15th, 2008, 06:38 PM
#11
Re: help me urgent
Originally Posted by TheCPUWizard
ANOTHER reason people (injcluding myself) is your refusal to use proper code tags....
please explain more!!
-
November 15th, 2008, 06:40 PM
#12
Re: help me urgent
Originally Posted by dky
please explain more!!
icic !i ald cancel the keyword "struct"
typedef struct{
int id;
char name;
char flightNo[40];
char date[20];
char time;
char gate;
char seatNo;
}customer;
customer cust[sizeR][sizeC];
-
November 15th, 2008, 08:22 PM
#13
Re: help me urgent
Originally Posted by dky
if(cust[row][col] != 0)
show by my compile ( binary '!=':'customer'does not define this operate or a conversion to a type acceptable to the predefined operator)
Yeah. I already told you why: Because a customer is not the same thing as an integer.
You're trying to check whether the seat is filled yet. What value within the customer struct would indicate that to you? If the answer is "you don't know", then that's the very first thing you need to answer.
-
November 15th, 2008, 11:24 PM
#14
Re: help me urgent
Originally Posted by dky
please explain more!!
Everything is explained in the FAQS, especially the one titled "BEFORE you Post" that is at the top of each forum.
These links are in my signature also. If you are not seeing my signature, then it means you ALSO did not setup your profile in accordance with the recomendations.
(It really suprises me how many people come "Begging" for help, but appear to be completely unwilling to do a little bit of research in order to learn how to use these forums effectivels)
TheCPUWizard is a registered trademark, all rights reserved. (If this post was helpful, please RATE it!)
2008, 2009,2010
In theory, there is no difference between theory and practice; in practice there is.
* Join the fight, refuse to respond to posts that contain code outside of [code] ... [/code] tags. See here for instructions
* How NOT to post a question here
* Of course you read this carefully before you posted
* Need homework help? Read this first
-
November 16th, 2008, 01:17 AM
#15
Re: help me urgent
Originally Posted by TheCPUWizard
Everything is explained in the FAQS, especially the one titled "BEFORE you Post" that is at the top of each forum.
These links are in my signature also. If you are not seeing my signature, then it means you ALSO did not setup your profile in accordance with the recomendations.
(It really suprises me how many people come "Begging" for help, but appear to be completely unwilling to do a little bit of research in order to learn how to use these forums effectivels)
i hv see FAQS ald.so now can tech me how to check array?
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|