Thread: this coding not complete yet,how to solve it.............?????

  1. #1
    Registered User
    Join Date
    Apr 2011
    Posts
    1

    this coding not complete yet,how to solve it.............?????

    #include<iostream>
    #include<iomanip>

    using namespace std;

    struct seat
    {
    int id;
    bool sold;
    string name;

    }seats[50];

    void update( );
    void available( );
    void showSold( );




    const int MAX_SEATS = 50;
    int seat;


    int main()
    {

    for( int i = 0; i < MAX_SEATS; i++ )
    seats[i].id = i+1;

    int selection;
    int choice;

    cout<<"1 - update reservation list\n"<<endl;
    cout<<"2 - show available seats\n"<<endl;
    cout<<"3 - show sold seats\n"<<endl;
    cout<<"0 - exit\n"<<endl;
    cout<<"Your selection 0..3 --> ";

    cin>>selection;

    if (choice=='0')
    cout<<"All done .....\n";
    else if(choice=='1')
    update();
    else if(choice=='2')
    available();
    else if(choice=='3')
    showSold();
    else
    cout<<"Not implemented yet...\n";

    return 0;
    system("pause");
    }



    void available()
    {
    cout << "Available seat id's:\n";

    for( int i = 0; i < MAX_SEATS; i++ )
    if( seats[i].sold == false )
    cout << setw(4) << seats[i].id;
    cout << endl;


    }

    void showSold( )
    {
    cout << "Sold seat id's:\n";
    for( int i = 0; i < MAX_SEATS; i++ )
    if( seats[i].sold == true )
    cout << setw(4) << seats[i].id << ": "
    << setw(14)<< seats[i].name ;
    cout << endl;
    }

    void update( )
    {
    {

    int num;
    if( num >= 1 && num <= MAX_SEATS && seats[num-1].sold == false )
    {
    seats[num-1].sold = true;
    cout << "Seat number " << num << " was sold to : ";
    cin>>seats[num-1].name ;
    }
    else
    cout << num << " is not available ...\n";
    }
    }

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Please:
    • Read the homework policy.
    • Post code in [code][/code] bbcode tags.
    • Indent your code properly.
    • Tell us what the code is supposed to do and how it is not working.
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. complete the gaps
    By transgalactic2 in forum C Programming
    Replies: 25
    Last Post: 07-03-2009, 04:07 PM
  2. c++ complete program
    By gaza rose in forum C++ Programming
    Replies: 7
    Last Post: 12-11-2008, 01:47 PM
  3. Help out a complete beginner
    By Jmcrofts in forum C++ Programming
    Replies: 7
    Last Post: 07-28-2007, 12:09 PM
  4. Complete Noob Needs Help
    By Shinobi in forum Windows Programming
    Replies: 2
    Last Post: 01-22-2007, 05:40 AM
  5. Yay! My first game is complete! Come look!
    By Leeman_s in forum Game Programming
    Replies: 2
    Last Post: 11-05-2001, 10:23 PM