How can I make this program work? Problem with arrays

This is a discussion on How can I make this program work? Problem with arrays within the C++ Programming forums, part of the General Programming Boards category; Code: #include<iostream> #include<string> using namespace std; void details( string fNum,int dHour,int dMin,int aHour,int aMin, string aircraft); int main() { //Flights ...

  1. #1
    Registered User
    Join Date
    Nov 2008
    Posts
    10

    How can I make this program work? Problem with arrays

    Code:
    #include<iostream>
    #include<string>
    
    using namespace std;
    void details( string fNum,int dHour,int dMin,int aHour,int aMin, string aircraft);
    
    int main()
    {
     //Flights tB:Trinidad-Barbados,tN:Trinidad to New York,tL:Trinidad to London.
            int dHour;
            int dMin;
            string fNum;
            int aHour;
            int aMin;
            int durHour;
            int durMin;
            string aircraft;
            int dOption;
            bool availabe=true;
            int seats[max_seat_rows][max_seat_cols]={0};
            int resAmt;
            int empty=0;
    
    //Recording Reservations for Passengers
            cout<<"\nWhat is your destination?\n"<<endl<<"1) Trinidad to Barbados"<<endl
                                                   <<"2) Trinidad to New York"<<endl
                                                   <<"3) Trinidad to London\n"<<endl;
            cout<<"Please enter either 1,2 or 3."<<endl;
            cin>>dOption;
    
            switch (dOption)
            {
                    case 1:
                            dHour=7;
                            dMin=0;
                            fNum="USC 215";
                            aHour=7;
                            aMin=45;
                            durHour=0;
                            durMin=45;
                            aircraft="MD 82";
                            max_seat_rows=15;
                            max_seat_cols=4;
    
    
                    break;
    
                    case 2:
                            dHour=6;
                            dMin=0;
                            fNum="USC 400";
                            aHour=3;
                            aMin=0;
                            durHour=6;
                            durMin=0;
                            aircraft="Boeing 737";
                            max_seat_rows=32;
                            max_seat_cols=6;
                    break;
    
                    case 3:
                            dHour=7;
                            dMin=30;
                            fNum="USC 900";
                            aHour=9;
                            aMin=30;
                            durHour=9;
                            durMin=0;
                            aircraft="Boeing 777";
                            max_seat_rows=30;
                            max_seat_cols=10;
                    break;
            }
    
    
                    details(fNum,dHour,dMin,aHour,aMin, aircraft);
    //This section declares everything in all of the arrays to 0;
    
    
                     for(int a=0;a<max_seat_rows;a++)
                     {
                            for(int b=0;b<max_seat_cols;b++)
                            {
                                    cout<<seats[a][b]<<"\t";
    
                            }
                            cout<<endl;
    
                     }
    
    // This section determines how many empty seats there are
    
                     for(int c=0;c<max_seat_rows;c++)
                     {
                            for(int d=0;d<max_seat_cols;d++)
                            {
                                    if (seats[c][d]==0)
                                    empty++;
    
                            }
                     }
    
                            cout<<"There are "<<empty<<" empty seats"<<endl;
    //This section takes the amount of seats that the user wishes to reserve and makes them unavailable
    
    
                            cout<<"How many seats would you like to reserve?"<<endl;
                            cin>>resAmt;
    
                            for (int e=0;e>resAmt;e++)
                            {
    
                                            for(int c=0;c<max_seat_rows;c++)
                                            {
                                                    for(int d=0;d<max_seat_cols;d++)
                                                    {
                                                            if (seats[c][d]==0)
                                                            {
                                                            seats[c][d]=1;
                                                            }
                                                            else
                                                            {
                                                            cout<<"This seat is already taken"<<endl;
                                                            }
    
                                                    }
                                            }
    
    
                            }
    
    return 0;
    
    
    }
    
    
                   void details( string fNum,int dHour,int dMin,int aHour,int aMin, string aircraft)
    {
                    cout<<"\n\nYou Have Chosen to Fly on Flight Number "<<fNum<<endl;
                    cout<<"The Flight will Depart at "<<dHour<<":"<<dMin<<endl;
                    cout<<"The Flight will Arrive at its Destination in "<<aHour<<" Hours and "<<aMin<<" Minutes"<<endl;
                    cout<<"Aircraft is the "<<aircraft<<endl;
    
    }
    These are the compiler errors

    seating.cpp: In function `int main()':
    seating.cpp:20: error: `max_seat_rows' undeclared (first use this function)
    seating.cpp:20: error: (Each undeclared identifier is reported only once for each function it appears in.)
    seating.cpp:20: error: `max_seat_cols' undeclared (first use this function)
    seating.cpp:84: error: `seats' undeclared (first use this function)
    Last edited by babe20042004; 12-21-2009 at 07:33 PM.

  2. #2
    Professional Chef leeor_net's Avatar
    Join Date
    Apr 2004
    Location
    Charles Town, WV
    Posts
    147
    What, exactly, isn't working about it?

    When asking about code
    - Leeor

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program problem
    By Birdhaus in forum C++ Programming
    Replies: 6
    Last Post: 11-21-2005, 10:37 PM
  2. how do you make a program send data to the printer?
    By Sintu in forum C++ Programming
    Replies: 19
    Last Post: 10-20-2005, 08:22 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 04:00 PM
  4. Crazy memory problem with arrays
    By fusikon in forum C++ Programming
    Replies: 9
    Last Post: 01-15-2003, 09:24 PM
  5. Results for the Encryption Contest -- June 23, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 07-07-2002, 09:04 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21