Thread: Select Menu and Call Function

  1. #1
    studentInC
    Guest

    Question Select Menu and Call Function

    Hello,

    I'm now studying in C. And I now making a simple program of Flight Ticket Reservation.

    I want to know the source code of
    the program ;

    i) select menu (switch case, ?)
    ii) call function ( display the list of data in alphabetical )
    iii) check booking ticket ( check & cancel )

    Hoping You Guys can tell me the source code.
    TQs.

  2. #2
    Me want cookie! Monster's Avatar
    Join Date
    Dec 2001
    Posts
    680

    Re: Select Menu and Call Function

    Originally posted by studentInC
    And I now making a simple program of Flight Ticket Reservation.

    I want to know the source code of
    the program ;
    Are you making it or do we have to make it for you?

    Anyways, if you are very lucky someone will give you the code (I don't), but that's not the way we do it here.

    You start making the program and when you have problems you post the code you've done so far and we will help you. That's how it works.

  3. #3
    Registered User
    Join Date
    Sep 2001
    Location
    Fiji
    Posts
    212
    dido to monster. The board has a strong philosophy that we don't write your programs. You write then and we may help.

  4. #4
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    now where did I leave that ticket reservation program? I had it all done for you and now I can't find it...

    seriously... write some code... and some bugs... post the bugs, we'll fix the bugs... see how it works?

  5. #5
    Perhaps you should rent a coder and have them do you program.

    That's how most CS students here (at my UNI) get their homework done.

    [bitterness] I knew there was I reason I could never get As in those classes! [/bitterness]

  6. #6
    Registered User rick barclay's Avatar
    Join Date
    Aug 2001
    Posts
    835
    I'll bet you're a scheming terrorist up to no good. I'm reporting
    this thread to the F.B.I.

    rick barclay
    No. Wait. Don't hang up!

    This is America calling!

  7. #7
    Mayor of Awesometown Govtcheez's Avatar
    Join Date
    Aug 2001
    Location
    MI
    Posts
    8,823
    Alright, guys, lay off...

    Point is, student - no one's going to do a full program for you. This program is pretty simple to do on your own. If not that, it's definitely not so difficult that you shouldn't be able to attempt it...

  8. #8
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    here it might help

    Code:
    #include <stdio.h>
    #include <stdlib.h>
    #define SIZE 10
    
    int main()
    {
     int seats[SIZE]= {0};
     int select, i=0, k = 5, cnt;
     static int I=0, K=10;
     char yn;
    
    
         while ((( I < 5 ) || ( k < 10))){
         printf( "\nPlease type 1 for First Class."
                 "\nPlease type 2 for Economy Class.");
         scanf ("%d", &select );
    
    
    
        if (  select == 1 ) {
        if ( I > 4  ){
              printf( "Sorry first class is taken do you need economy class[y/n]: ");
              scanf ("%s", &yn );
           
           if ( yn == 'y' ){
           printf ("\nEconomy Class. Seat number %d\n", k+1 );
           ++seats[k++];
           }
           else if ( yn == 'n' ) {
           printf ("\nNext Flight leaves in 3 hours\n");
           break;} }
        else {
        printf ("\nFirst Class .Seat number %d\n", I+1 );
           ++seats[i++];
           I++;   }
                   }
    
        else if ( select == 2 ){
    
               if ( K > 10 ){
               printf ("\nNow there arnt any seats for economy class\n");
               }
    
               else {
               printf ("\nEconomy Class. Seat number %d\n", k+1 );
               ++seats[k++];
               K = k+1;}}
          }
    
    
      printf( "----------VIRGIN ATLANTIC----------\n"
              "     No more seats are avaiable\n"
              "----------From 1980 to 2002--------\n");
    
    
    
          system("PAUSE");
          return 0;
    }
    Here is the code u need ....
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  9. #9
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    >>Here is the code u need ....
    I disagree. The student needs to write his/her own code, or at least try to first. Reading and/or using someone elses code that does exactly what they asked for doesn't help teach, imho. The student should be left with something to work out for themselves.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  10. #10
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,897
    >The student should be left with something to work out for themselves.
    It also isn't wise to give students complete source because if they are tempted to turn it in the teacher may determine that it was written by somebody else (which it was) and either give a mark of zero for the project or have the student expelled for cheating. We aren't just being stuffy, not doing homework for others has a very sound and reasonable foundation.

    -Prelude
    My best code is written with the delete key.

  11. #11
    Registered User datainjector's Avatar
    Join Date
    Mar 2002
    Posts
    356

    hold up...

    yeah prelude ur right i should have thought about that ..Flaming me
    "I wish i could wish my wishs away"

    "By indirections find directions out" -- William Shakespears

    "Do what thou wilt shall be the whole of the law" -- Crowley "THE BEAST 666"

    Mizra -> love = Death...
    RDB(Rocks yooo)..

    http://www.cbeginnersunited.com

    Are you ready for the Trix ???

  12. #12
    5|-|1+|-|34|) ober's Avatar
    Join Date
    Aug 2001
    Posts
    4,429
    here's a thought datainjector... how hard would it be for a prof to come on here after posting an assignment and look for people getting help, and then find that someone gave them all the code?

    For all we know, you just got that kid a big fat zero.
    EntropySink. You know you have to click it.

  13. #13
    Registered User
    Join Date
    Dec 2002
    Posts
    10
    I was taking a course in C last semester, but ended up missing some classes mostly due to job commitment, and falling behind. We had a similiar program to writefor our class that I was having problems with coding. I have a few questions on your program code that I was hoping you could answer.


    #include <stdlib.h>

    What does this library do for this program?


    int select, i=0, k = 5, cnt;
    static int I=0, K=10;

    What does the static int do for you that a regular int won't do?

    system("PAUSE");

    What does this command do?

  14. #14
    and the Hat of Clumsiness GanglyLamb's Avatar
    Join Date
    Oct 2002
    Location
    between photons and phonons
    Posts
    1,110
    Coming from BC 4.52
    Static:Use the static storage class specifier with a local variable to preserve the last value between successive calls to that function. A static variable acts like a local variable but has the lifetime of an external variable.
    stdlib.heclares several commonly used routines such as conversion routines and search/sort routines.
    system("PAUSE"); this prevents from the window flashing away when the app is done ....works like getchar(); while(!kbhit());
    sleep(seconds);etc...

  15. #15
    Programming Sex-God Polymorphic OOP's Avatar
    Join Date
    Nov 2002
    Posts
    1,078

    Re: here it might help

    Originally posted by datainjector
    Here is the code u need ....
    Or you can just use an array of function pointers and use the number input by the user as the index in the array -- that way you can call the appropriate function without having to do any checks at all (except to make sure it is a valid index).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 2
    Last Post: 02-27-2009, 12:46 PM
  2. Data Structures Warning
    By jlharrison in forum C Programming
    Replies: 6
    Last Post: 04-08-2006, 12:04 AM
  3. Constructive Feed Back (Java Program)
    By xddxogm3 in forum Tech Board
    Replies: 12
    Last Post: 10-10-2004, 03:41 AM
  4. passing counters between function
    By BungleSpice in forum C Programming
    Replies: 18
    Last Post: 02-21-2004, 06:16 PM
  5. Menu Item Caption - /a for right aligned Accelerator?
    By JasonD in forum Windows Programming
    Replies: 6
    Last Post: 06-25-2003, 11:14 AM