Apr 18, 2013 at 4:23pm Apr 18, 2013 at 4:23pm UTC
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main()
{
int airplane[13][6];
char airchar[13][6];
string ticket;
int row[2];
char seat;
//--------------------------------------------
for (int i = 0; i < 13; i++)
{
for (int j = 0; j < 6; j++)
{
airchar[i][j] = '*' ;
airplane[i][j] = 0;
}
}
//--------------------------------------------
for (;;)
{
cout<<"Rows 1 and 2 are first class (FC)" <<endl;
cout<<"Rows 3 through 7 are business class (BC)" <<endl;
cout<<"Rows 8 through 13 are economy class (EC)" <<endl;
cout<<endl;
cout<<"* - Available" <<endl;
cout<<"X - Occupied" <<endl;
cout<<endl;
cout<<" \tA\tB\tC\tD\tE\tF" <<endl;
cout<<"Row 1\t" <<airchar[0][0]<<"\t" <<airchar[0][1]<<"\t"
<<airchar[0][2]<<"\t" <<airchar[0][3]<<"\t" <<airchar[0][4]<<"\t"
<<airchar[0][5]<<endl;
cout<<"Row 2\t" <<airchar[1][0]<<"\t" <<airchar[1][1]<<"\t"
<<airchar[1][2]<<"\t" <<airchar[1][3]<<"\t" <<airchar[1][4]<<"\t"
<<airchar[1][5]<<endl;
cout<<"Row 3\t" <<airchar[2][0]<<"\t" <<airchar[2][1]<<"\t"
<<airchar[2][2]<<"\t" <<airchar[2][3]<<"\t" <<airchar[2][4]<<"\t"
<<airchar[2][5]<<endl;
cout<<"Row 4\t" <<airchar[3][0]<<"\t" <<airchar[3][1]<<"\t"
<<airchar[3][2]<<"\t" <<airchar[3][3]<<"\t" <<airchar[3][4]<<"\t"
<<airchar[3][5]<<endl;
cout<<"Row 5\t" <<airchar[4][0]<<"\t" <<airchar[4][1]<<"\t"
<<airchar[4][2]<<"\t" <<airchar[4][3]<<"\t" <<airchar[4][4]<<"\t"
<<airchar[4][5]<<endl;
cout<<"Row 6\t" <<airchar[5][0]<<"\t" <<airchar[5][1]<<"\t"
<<airchar[5][2]<<"\t" <<airchar[5][3]<<"\t" <<airchar[5][4]<<"\t"
<<airchar[5][5]<<endl;
cout<<"Row 7\t" <<airchar[6][0]<<"\t" <<airchar[6][1]<<"\t"
<<airchar[6][2]<<"\t" <<airchar[6][3]<<"\t" <<airchar[6][4]<<"\t"
<<airchar[6][5]<<endl;
cout<<"Row 8\t" <<airchar[7][0]<<"\t" <<airchar[7][1]<<"\t"
<<airchar[7][2]<<"\t" <<airchar[7][3]<<"\t" <<airchar[7][4]<<"\t"
<<airchar[7][5]<<endl;
cout<<"Row 9\t" <<airchar[8][0]<<"\t" <<airchar[8][1]<<"\t"
<<airchar[8][2]<<"\t" <<airchar[8][3]<<"\t" <<airchar[8][4]<<"\t"
<<airchar[8][5]<<endl;
cout<<"Row 10\t" <<airchar[9][0]<<"\t" <<airchar[9][1]<<"\t"
<<airchar[9][2]<<"\t" <<airchar[9][3]<<"\t" <<airchar[9][4]<<"\t"
<<airchar[9][5]<<endl;
cout<<"Row 11\t" <<airchar[10][0]<<"\t" <<airchar[10][1]<<"\t"
<<airchar[10][2]<<"\t" <<airchar[10][3]<<"\t" <<airchar[10][4]<<"\t"
<<airchar[10][5]<<endl;
cout<<"Row 12\t" <<airchar[11][0]<<"\t" <<airchar[11][1]<<"\t"
<<airchar[11][2]<<"\t" <<airchar[11][3]<<"\t" <<airchar[11][4]<<"\t"
<<airchar[11][5]<<endl;
cout<<"Row 13\t" <<airchar[12][0]<<"\t" <<airchar[12][1]<<"\t"
<<airchar[12][2]<<"\t" <<airchar[12][3]<<"\t" <<airchar[12][4]<<"\t"
<<airchar[12][5]<<endl;
cout<<endl;
cout<<"Enter Ticket type (FC, BC, or EC): " ;
cin>>ticket;
cout<<"Desired Row: " ;
cin>>row[0];
cout<<"Desired seat (A,B,C,D,E or F): " ;
cin>>seat;
switch (seat)
{
case 'A' :
case 'a' :
row[0] = row[0] - 1;
row[1] = 1;
row[1] = row[1] - 1;
break ;
case 'B' :
case 'b' :
row[0] = row[0] - 1;
row[1] = 2;
row[1] = row[1] - 1;
break ;
case 'C' :
case 'c' :
row[0] = row[0] - 1;
row[1] = 3;
row[1] = row[1] - 1;
break ;
case 'D' :
case 'd' :
row[0] = row[0] - 1;
row[1] = 4;
row[1] = row[1] - 1;
break ;
case 'E' :
case 'e' :
row[0] = row[0] - 1;
row[1] = 5;
row[1] = row[1] - 1;
break ;
case 'F' :
case 'f' :
row[0] = row[0] - 1;
row[1] = 6;
row[1] = row[1] - 1;
break ;
}
if (ticket == "FC" )
{
if (row[0]+1 == 1 || row[0]+1 == 2)
{
if (airplane[row[0]][row[1]] == 0)
{
airplane[row[0]][row[1]] = 1;
airchar[row[0]][row[1]] = 'X' ;
}
else if (airplane[row[0]][row[1]] == 1)
{
cout<<"Message: Seat " <<row[0] + 1<<seat<<" is already occupied" <<endl;
system("Pause" );
}
}
else
{
cout<<"Wrong Class" <<endl;
system("Pause" );
system("cls" );
continue ;
}
}
else if (ticket == "BC" )
{
if (row[0]+1 == 3 || row[0]+1 == 4 || row[0]+1 == 5
|| row[0]+1 == 6|| row[0]+1 == 7)
{
if (airplane[row[0]][row[1]] == 0)
{
airplane[row[0]][row[1]] = 1;
airchar[row[0]][row[1]] = 'X' ;
}
else if (airplane[row[0]][row[1]] == 1)
{
cout<<"Message: Seat " <<row[0] + 1<<seat<<" is already occupied" <<endl;
system("Pause" );
}
}
else
{
cout<<"Wrong Class" <<endl;
system("Pause" );
system("cls" );
continue ;
}
}
else if (ticket == "EC" )
{
if (row[0]+1 == 8 || row[0]+1 == 9 || row[0]+1 == 10
|| row[0]+1 == 11|| row[0]+1 == 12|| row[0]+1 == 13)
{
if (airplane[row[0]][row[1]] == 0)
{
airplane[row[0]][row[1]] = 1;
airchar[row[0]][row[1]] = 'X' ;
}
else if (airplane[row[0]][row[1]] == 1)
{
cout<<"Message: Seat " <<row[0] + 1<<seat<<" is already occupied" <<endl;
system("Pause" );
}
}
else
{
cout<<"Wrong Class" <<endl;
system("Pause" );
system("cls" );
continue ;
}
}
row[0] = 0;
row[1] = 0;
system("cls" );
}
return 0;
}
Okay Guys, My Output table looks like this right now...
A B C D E F
Row 1 * * * * * *
Row 2 * * * * * *
Row 3 * * * * * *
Row 4 * * * * * *
Row 5 * * * * * *
Row 6 * * * * * *
Row 7 * * * * * *
Row 8 * * * * * *
Row 9 * * * * * *
Row 10 * * * * * *
Row 11 * * * * * *
Row 12 * * * * * *
Row 13 * * * * * *
But I need it to look like this...
A B C D E F
Row 1 * * X * X X
Row 2 * X X * * X
Row 3 * * X X * *
Row 4 X * X * X X
Row 5 * * * X X X
Row 6 * X * * * X
Row 7 X X X X X X
Row 8 * * * X X *
Row 9 X X * * * *
Row 10 * * * * X X
Row 11 * * * * * *
Row 12 X X X * * *
Row 13 * * X X * *
Last edited on Apr 18, 2013 at 4:40pm Apr 18, 2013 at 4:40pm UTC
Apr 18, 2013 at 4:27pm Apr 18, 2013 at 4:27pm UTC
I'm just saying this and will keep copying and pasting and improving it with every thread I see like this.
Are you asking your questions correctly? Posters that follow these guidelines are much more likely to have someone work with them to solve their problems.
1) Use codetags whenever you post any code to the forums. If you don't know what they are find out.
2) Relate what you are having problems with specifically. Don't just post "I need help with this" and a wall of code. Tell us exactly what you don't get or exactly what you problem is with very detailed information and code to back it up.
3) If you have error codes post what they are which line they are on and what you have tried to do to correct them. Not just "I have errors help".
4) Be polite. Most people don't have to help you out if they didn't want to, so don't throw their answers back in their face or anything and always be thankful they took time out of their day to help. Also be patient sometimes it takes awhile for someone to log on that knows about your problem and can answer it. If you keep posting it over and over you reduce you chances to be answered.
5) One of the most important. Be willing to learn and do research for yourself. We will help you get through a problem but we won't do it for you. We might give you links to things that might help or snippets of code. It is up to you to go through that and find what you need, not us to tell you exactly what to do.
Last edited on Apr 18, 2013 at 4:27pm Apr 18, 2013 at 4:27pm UTC
Apr 18, 2013 at 4:37pm Apr 18, 2013 at 4:37pm UTC
Sorry, :[
It was just one piece of the program that i need help with.
The program I posted in the OP as a whole works perfectly fine, and there is nothing wrong with it.
I just wanted to know how to change certain *'s into X's
that's all.
lines 15-25
Last edited on Apr 18, 2013 at 4:40pm Apr 18, 2013 at 4:40pm UTC
Apr 18, 2013 at 4:46pm Apr 18, 2013 at 4:46pm UTC
hey! i actually just figured it out on my own :D
no help needed anymore (close thread)