help me urgent
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 15 of 33

Thread: help me urgent

Hybrid View

  1. #1
    Join Date
    Nov 2008
    Posts
    20

    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

  2. #2
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: help me urgent

    No, not gonna do your homework for you. Besides, airline booking is annoying enough in reality.

  3. #3
    Join Date
    Nov 2008
    Posts
    20

    Re: help me urgent

    help me!!!i dont know how to do the looping to check that array have element or not!!? help

  4. #4
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: help me urgent

    Quote Originally Posted by dky View Post
    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("&#37;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 09:20 AM.

  5. #5
    Join Date
    Nov 2008
    Posts
    20

    Re: help me urgent

    Quote Originally Posted by Lindley View Post
    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("&#37;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)

  6. #6
    Join Date
    Nov 2008
    Posts
    20

    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);

  7. #7
    Lindley is offline Elite Member Power Poster
    Join Date
    Oct 2007
    Location
    Fairfax, VA
    Posts
    10,888

    Re: help me urgent

    Quote Originally Posted by dky View Post
    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.

  8. #8
    Join Date
    Nov 2008
    Posts
    20

    Re: help me urgent

    Quote Originally Posted by Lindley View Post
    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!!!

  9. #9
    Join Date
    Sep 2004
    Location
    Holland (land of the dope)
    Posts
    4,123

    Exclamation Re: help me urgent

    This is why nobody is replying.

  10. #10
    Join Date
    Nov 2008
    Posts
    20

    Re: help me urgent

    Quote Originally Posted by Skizmo View Post
    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

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
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center