'*' to 'X'..................

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Jun 2008
Posts: 48
Reputation: sniper29 has a little shameless behaviour in the past 
Solved Threads: 0
sniper29 sniper29 is offline Offline
Light Poster

'*' to 'X'..................

 
-1
  #1
Jun 11th, 2008
i have here a code.....

can anybody tell me how to 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();
}
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 48
Reputation: sniper29 has a little shameless behaviour in the past 
Solved Threads: 0
sniper29 sniper29 is offline Offline
Light Poster

Re: '*' to 'X'..................

 
0
  #2
Jun 11th, 2008
how can i change the ' * ' if a user inputs

his desired seat.... and change it to ' x '.....
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 280
Reputation: joshmo is an unknown quantity at this point 
Solved Threads: 19
joshmo joshmo is offline Offline
Posting Whiz in Training

Re: '*' to 'X'..................

 
0
  #3
Jun 11th, 2008
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
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 48
Reputation: sniper29 has a little shameless behaviour in the past 
Solved Threads: 0
sniper29 sniper29 is offline Offline
Light Poster

Re: '*' to 'X'..................

 
0
  #4
Jun 11th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 280
Reputation: joshmo is an unknown quantity at this point 
Solved Threads: 19
joshmo joshmo is offline Offline
Posting Whiz in Training

Re: '*' to 'X'..................

 
0
  #5
Jun 11th, 2008
why dont you use something like a "1" and "0"..if the seat is booked then set it to 1 else to 0..
Reply With Quote Quick reply to this message  
Join Date: Jan 2008
Posts: 3,828
Reputation: VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute VernonDozier has a reputation beyond repute 
Solved Threads: 501
Featured Poster
VernonDozier VernonDozier is offline Offline
Senior Poster

Re: '*' to 'X'..................

 
0
  #6
Jun 11th, 2008
  1. #include<iostream.h>
  2. #include<conio.h>
  3. #include<iomanip.h>
  4. int userInput();
  5. int main()
  6.  
  7. {
  8. clrscr();
  9. int x,y;
  10. const int row= 12,seat= 5;
  11. char plane[row][seat];
  12. cout<<"\t\tAirplane Seat Arrangement"<<endl;
  13. cout<<"\tA\tB\tC\tD\tE\tF"<<endl;
  14. {for (y=1;y<=13;y++)
  15. { cout<<"Row "<<y<<"\t";
  16. {for(x=0;x<=5;x++)
  17. { plane[y][x]='*';
  18. cout<<plane[y][x]<<"\t";
  19. }
  20. cout<<endl;
  21. }
  22. }
  23. }
  24. userInput();
  25. cout<<"Congratulations!! You Now Have A Seat...."
  26. <<" Happy Trip!!!";
  27.  
  28. getch();
  29. return 0;
  30. }
  31.  
  32. int userInput()
  33. {int tt,tr,nsa;
  34. int a,b;
  35. const int row= 12,seat= 5;
  36. char plane[row][seat];
  37. char tc;
  38. char A=1;
  39. char B=2;
  40. char C=3;
  41. char D=4;
  42. char E=5;
  43. char F=6;
  44. cout<<"\nEnter TICKET TYPE [1]First Class [2]Economy Class : ";
  45. cin>>tt;
  46. switch(tt)
  47. {case 1:
  48. {
  49. {cout<<"Enter TICKET [1-2]ROW NUMBER : ";
  50. cin>>tr;
  51. { if ((tr>=1)&&(tr<=2))
  52. cout<<"Input Accepted..."<<endl<<endl;
  53. else
  54. cout<<"Invalid Input!!!"<<endl<<endl;
  55. cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
  56. cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
  57. cin>>tc;
  58. if ((tc>='A')&&(tc<='F'))
  59. cout<<"Input Accepted..."<<endl<<endl;
  60. else
  61. cout<<"Invalid Input!!!"<<endl<<endl; }
  62. }
  63. {
  64. for (a=0;a<=2;a++)
  65. for (b=0;b<=5;b++)
  66. plane[a][b] ='X'; }
  67. cout<<plane[a][b];
  68. }
  69. break;
  70. case 2:
  71. {cout<<"[1]Non-Smoking Area [2]Smoking Area : ";
  72. cin>>nsa;
  73. switch(nsa)
  74. {case 1:
  75. {cout<<"Enter TICKET [3-7]ROW NUMBER : ";
  76. cin>>tr;
  77. { if ((tr>=3)&&(tr<=7))
  78. cout<<"Input Accepted..."<<endl<<endl;
  79. else
  80. cout<<"Invalid Input!!!"<<endl<<endl;
  81. cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
  82. cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
  83. cin>>tc;
  84. if ((tc>='A')&&(tc<='F'))
  85. cout<<"Input Accepted..."<<endl<<endl;
  86. else
  87. cout<<"Invalid Input!!!"<<endl<<endl;
  88. } }break;
  89. case 2:
  90. {cout<<"Enter TICKET [8-13]ROW NUMBER : ";
  91. cin>>tr;
  92. { if ((tr>=8)&&(tr<=13))
  93. cout<<"Input Accepted..."<<endl<<endl;
  94. else
  95. cout<<"Invalid Input!!!"<<endl<<endl;
  96. cout<<"Note : Letter is CASE SENSITIVE!!!"<<endl;
  97. cout<<"Enter TICKET [A-F]COLUMN LETTER : ";
  98. cin>>tc;
  99. if ((tc>='A')&&(tc<='F'))
  100. cout<<"Input Accepted..."<<endl<<endl;
  101. else
  102. cout<<"Invalid Input!!!"<<endl<<endl;
  103. }break;
  104. default:
  105. cout<<"INVALID INPUT!!!"<<endl;break;
  106. } }
  107. }
  108. default:
  109. cout<<"INVALID INPUT!!!"<<endl;break;
  110. }
  111. return userInput();
  112. }

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:
  1. 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.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 48
Reputation: sniper29 has a little shameless behaviour in the past 
Solved Threads: 0
sniper29 sniper29 is offline Offline
Light Poster

Re: '*' to 'X'..................

 
0
  #7
Jun 11th, 2008
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++...
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 48
Reputation: sniper29 has a little shameless behaviour in the past 
Solved Threads: 0
sniper29 sniper29 is offline Offline
Light Poster

Re: '*' to 'X'..................

 
0
  #8
Jun 11th, 2008
#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????
Reply With Quote Quick reply to this message  
Join Date: Jul 2005
Posts: 1,688
Reputation: Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all Lerner is a name known to all 
Solved Threads: 266
Lerner Lerner is offline Offline
Posting Virtuoso

Re: '*' to 'X'..................

 
0
  #9
Jun 11th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Oct 2007
Posts: 280
Reputation: joshmo is an unknown quantity at this point 
Solved Threads: 19
joshmo joshmo is offline Offline
Posting Whiz in Training

Re: '*' to 'X'..................

 
1
  #10
Jun 11th, 2008
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
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC