i have here a code.....

can anybody tell me how to:-O change the '*' to 'X' when a user will input his desired seat.....
:(

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int userInput();
int main()

{
clrscr();
int x,y;
const int row= 12,seat= 5;
char plane[row][seat];
cout<<"\t\tAirplane Seat Arrangement"<<endl;
cout<<"\tA\tB\tC\tD\tE\tF"<<endl;
{for (y=1;y<=13;y++)
  {   cout<<"Row "<<y<<"\t";
            {for(x=0;x<=5;x++)
                 {  plane[y][x]='*';
                            cout<<plane[y][x]<<"\t";
                    }
                    cout<<endl;
                }
            }
}
userInput();
cout<<"Congratulations!! You Now Have A Seat...."
        <<" Happy Trip!!!";

getch();
return 0;
}

int userInput()
{int tt,tr,nsa;
int a,b;
const int row= 12,seat= 5;
char plane[row][seat];
char tc;
char A=1;
char B=2;
char C=3;
char D=4;
char E=5;
char F=6;
    cout<<"\nEnter TICKET TYPE [1]First Class [2]Economy Class : ";
    cin>>tt;
        switch(tt)
        {case 1:
          {
                {cout<<"Enter TICKET [1-2]ROW NUMBER : ";
                cin>>tr;
                  {     if ((tr>=1)&&(tr<=2))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl;
                        cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
                    cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                        cin>>tc;
                    if ((tc>='A')&&(tc<='F'))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl; }
                        }
                      {
                        for (a=0;a<=2;a++)
                        for (b=0;b<=5;b++)
                          plane[a][b] ='X';  }
                            cout<<plane[a][b];
                        }
                break;
         case 2:
            {cout<<"[1]Non-Smoking Area [2]Smoking Area : ";
                cin>>nsa;
                    switch(nsa)
                        {case 1:
                            {cout<<"Enter TICKET [3-7]ROW NUMBER : ";
                            cin>>tr;
                          {     if ((tr>=3)&&(tr<=7))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl;
                        cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
                            cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                            cin>>tc;
                            if ((tc>='A')&&(tc<='F'))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl;
                         }  }break;
                        case 2:
                            {cout<<"Enter TICKET [8-13]ROW NUMBER : ";
                            cin>>tr;
                             {  if ((tr>=8)&&(tr<=13))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl;
                        cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
                            cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                            cin>>tc;
                            if ((tc>='A')&&(tc<='F'))
                        cout<<"Input Accepted..."<<endl<<endl;
                    else
                        cout<<"Invalid Input!!!"<<endl<<endl;
                            }break;
                        default:
                            cout<<"INVALID INPUT!!!"<<endl;break;
                     }  }
             }
              default:
                    cout<<"INVALID INPUT!!!"<<endl;break;
        }
return userInput();
    }

Edited 3 Years Ago by Dani: Formatting fixed

Comments
It's about time you learnt how to use code tags :(

how can i change the ' * ' if a user inputs

his desired seat.... and change it to ' x '.....

Ummm. What are you suposed to do?? what is the whole point of using a "*" then changing it to x?? can you put your question more clearly

i am near to finish if i can do that......

for those who can help me....

thhank you...

(Airplane Seating Assignment) Write a program that can be used to assign seats for a commercial airplane. The airplane has 13 rows, with 6 seats in each row. Rows 1 and 2 are first class; the remaining rows are economy class. Also, rows 1 through 7 are nonsmoking. Your program must prompt the user to enter the following information:

Here, * indicates that the seat is available; X indicates that the seat is occupied. Make this a menu-driven program; show the user’s choices and allow the user to make the appropriate choices.

why dont you use something like a "1" and "0"..if the seat is booked then set it to 1 else to 0..

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
int userInput();
int main()

{
clrscr();
int x,y;
const int row= 12,seat= 5;
char plane[row][seat];
cout<<"\t\tAirplane Seat Arrangement"<<endl;
cout<<"\tA\tB\tC\tD\tE\tF"<<endl;
{for (y=1;y<=13;y++)
{ cout<<"Row "<<y<<"\t";
{for(x=0;x<=5;x++)
{ plane[y][x]='*';
cout<<plane[y][x]<<"\t";
}
cout<<endl;
}
}
}
userInput();
cout<<"Congratulations!! You Now Have A Seat...."
<<" Happy Trip!!!";

getch();
return 0;
}

int userInput()
{int tt,tr,nsa;
int a,b;
const int row= 12,seat= 5;
char plane[row][seat];
char tc;
char A=1;
char B=2;
char C=3;
char D=4;
char E=5;
char F=6;
cout<<"\nEnter TICKET TYPE [1]First Class [2]Economy Class : ";
cin>>tt;
switch(tt)
{case 1:
{
{cout<<"Enter TICKET [1-2]ROW NUMBER : ";
cin>>tr;
{ if ((tr>=1)&&(tr<=2))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl;
cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
cin>>tc;
if ((tc>='A')&&(tc<='F'))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl; }
}
{
for (a=0;a<=2;a++)
for (b=0;b<=5;b++)
plane[a][b] ='X'; }
cout<<plane[a][b];
}
break;
case 2:
{cout<<"[1]Non-Smoking Area [2]Smoking Area : ";
cin>>nsa;
switch(nsa)
{case 1:
{cout<<"Enter TICKET [3-7]ROW NUMBER : ";
cin>>tr;
{ if ((tr>=3)&&(tr<=7))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl;
cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
cin>>tc;
if ((tc>='A')&&(tc<='F'))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl;
} }break;
case 2:
{cout<<"Enter TICKET [8-13]ROW NUMBER : ";
cin>>tr;
{ if ((tr>=8)&&(tr<=13))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl;
cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
cin>>tc;
if ((tc>='A')&&(tc<='F'))
cout<<"Input Accepted..."<<endl<<endl;
else
cout<<"Invalid Input!!!"<<endl<<endl;
}break;
default:
cout<<"INVALID INPUT!!!"<<endl;break;
} }
}
default:
cout<<"INVALID INPUT!!!"<<endl;break;
}
return userInput();
}

You need to format and use code tags.

[code=cplusplus] // paste code here

[/code]

Your code is very hard to read due to to the lack of indentation. You also have a whole bunch of extra brackets that do nothing. The compiler doesn't care about the extra brackets, but combined with the lack of indentation, it makes it hard to tell where code blocks begin and end.

You already have your array set up. When a person buys a seat, he/she will be assigned a row and a seat. '*' means the seat is empty, 'X' means it is taken. So when you reserve a seat at row myRowNum and seat mySeatNum, you'll do this:

plane[myRowNum][mySeatNum] = 'X';

Depending on how you want to organize your program, you'll need to change the userInput function so that it can somehow do something with that row and seat number once you get valid input. You'll either need to pass it your array or pass the row and seat numbers by reference so you can use them when the function returns to main(), or something similar.

awhere will i put it?????

i had already tried it and it dont do anything....

will i put it after the row and seat number is entered????

im just a begginer hehehe.....

sori for my bad writing style on c++...

#include<iostream.h>
#include<conio.h>
#include<iomanip.h>
void userInput();
int main()

{
clrscr();
int x,y;
const int row= 12,seat= 5;
char plane[row][seat];
cout<<"\t\tAirplane Seat Assignment"<<endl;
cout<<"\tA\tB\tC\tD\tE\tF"<<endl;
{for (y=1;y<=13;y++)
  {   cout<<"Row "<<y<<"\t";
            {for(x=0;x<=5;x++)
                 {  plane[y][x]='*';
                            cout<<plane[y][x]<<"\t";
                    }
                    cout<<endl;
                }
            }
}
userInput();
cout<<"Congratulations!! You Now Have A Seat...."
        <<" Happy Trip!!!";

getch();
return 0;
}
void userInput()
{
const int row= 12,seat= 5;
char plane[row][seat];
int code = plane[row][seat];
int tt,nsa;
char tc;
char A=1;
char B=2;
char C=3;
char D=4;
char E=5;
char F=6;
cout<<"\nEnter TICKET TYPE [1]First Class [2]Economy Class : ";
    cin>>tt;
    switch(tt)
    {
        case 1:
            {
            cout<<"Enter TICKET [1-2]ROW NUMBER : ";
            cin>>tt;
                { if((tt>=1)&&(tt<=2))
                    cout<<"Row Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
            cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
             cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                cin>>tc;
                { if ((tc>='A')&&(tc<='F'))
                    cout<<"Column Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
                  plane[tt][tc] = 'X';
                  cout<<plane<<endl;
            } break;
        case 2:
            {
            cout<<"Enter if [1]Non-Smoking Area or [2]Smoking Area : ";
            cin>>nsa;
                switch(nsa)
                    {
                        case 1:
                {
            cout<<"Enter TICKET [3-7]ROW NUMBER : ";
            cin>>tt;
                { if((tt>=3)&&(tt<=7))
                    cout<<"Row Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
            cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
             cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                cin>>tc;
                { if ((tc>='A')&&(tc<='F'))
                    cout<<"Column Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
                  } break;
                  case 2:
                  {cout<<"Enter TICKET [8-13]ROW NUMBER : ";
            cin>>tt;
                { if((tt>=8)&&(tt<=13))
                    cout<<"Row Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
            cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
             cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
                cin>>tc;
                { if ((tc>='A')&&(tc<='F'))
                    cout<<"Column Accepted"<<endl<<endl;
                  else
                    cout<<"Invalid"<<endl<<endl;
                  }
                  } break;

                  }
                } break;
        default:
            cout<<"INVALID"<<endl;break;
    }
}

here now is my code......

and it output:
0x239f24dc

whats wrong with my code????

Edited 3 Years Ago by Dani: Formatting fixed

Lot's of things.

My first tip, never write more than a few lines, and clearly never more than a single action, without compiling and testing. By doing that you would find that you are overwriting your array and getting junk. Be sure you can initialize all elements of the variable plane to valid default values and display the state of the plane before you do anything else.

Can you please use code tags and indent your code well for proper reading. I bet alot of people here are not trying to read the code because it is really not easy to read. Stop having the mentality that you are a newbie and you dont know anythin. Remeber people learn from their mistakes and if it has already been pointed out then please try to change. More infomation here and here. Please make a point to read both links

Comments
You're damn right!

Ditto what Lerner and joshmo said. See my earlier post regarding code tags, extra brackets, and formatting/indentation, as well as joshmo's links.

const int row= 12,seat= 5;
char plane[row][seat];
cout<<"\t\tAirplane Seat Assignment"<<endl;
cout<<"\tA\tB\tC\tD\tE\tF"<<endl;
{for (y=1;y<=13;y++)
{ cout<<"Row "<<y<<"\t";
{for(x=0;x<=5;x++)
{ plane[y][x]='*';

Line 8 - Plane is defined for row indexes 0 through 11 in line 3. C++ arrays start with index 0, not 1. y is allowed to equal 13 in this loop. x is allowed to be 5. So you are defining in line 8, at some point, this:

plane[13][5] = '*';

plane[][] is only defined through plane[11][4]. That may not cause you problems, but that would be dumb luck if it doesn't. You need to change your array indexing so it starts at 0, or allocate more space.

This article has been dead for over six months. Start a new discussion instead.