Problem with data extraction

I'm not sure why, but when I prompt the user to enter the seat column (a=1,b=2,etc.) and seat row (1-13, i believe), it will only allow him/her to type in the seat column. After this point, the program terminates.

Here's the code:
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
#include <cstdlib>
#include <iostream>
#include <iomanip>
using namespace std;
void ticketchoices();
void displaychartfirst(char firstclass[2][6],int ticketnumselection);
void displaychartbus(char busiclass[5][6],int ticketnumselection);
void displaycharteco(char ecoclass[6][6],int ticketnumselection);



int main(int argc, char *argv[])
{
char X;
char O;
char firstclass[2][6]={{'O','O','X','O','X','X'},  //first class array.
                       {'O','X','O','X','O','X'}};
char busiclass[5][6]= {{'O','O','X','X','O','X'},  //business class array.
                       {'X','O','X','O','X','X'},
                       {'O','X','O','X','O','O'},
                       {'O','X','O','O','O','X'},
                       {'X','O','O','O','X','X'}};
char ecoclass[6][6]=  {{'O','X','O','X','X','O'},  //economy class array.
                       {'X','O','X','X','O','X'},
                       {'O','X','O','X','X','X'},
                       {'O','O','X','O','X','O'},
                       {'O','O','X','X','O','X'},
                       {'O','O','O','O','X','O'}};
int ticketnumselection;
int a=0,A=0,b=1,B=1,c=2,C=2,d=3,D=3,e=4,E=4,f=5,F=5;
cout<<"Welcome! Please, select a ticket type:"<<endl;
ticketchoices();
cout<<endl;
cout<<"Enter choice: ";
cin>>ticketnumselection;
cout<<endl;
switch(ticketnumselection)
{case 1: cout<<"You've chosen first class."<<endl<<endl;
         break;
 case 2: cout<<"You've chosen business class."<<endl<<endl;
         break;
 case 3: cout<<"You've chosen economy class."<<endl<<endl;
         break;}
displaychartfirst(firstclass,ticketnumselection);
displaychartbus(busiclass,ticketnumselection);
displaycharteco(ecoclass,ticketnumselection);
int sr1,sc1,sr2,sc2,sr3,sc3;
if(ticketnumselection==1)
{
cout<<"Please, enter your seat position, below (Example: A2):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc1;
}
if(ticketnumselection==1)
{
cout<<"Enter row number: ";
cin>>sr1;
}
 
if(ticketnumselection==2)
{
cout<<"Please, enter your seat position, below (Example: C3):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc2;
cout<<"Enter row number: ";
cin>>sr2;
}

if(ticketnumselection==3)
{
cout<<"Please, enter your seat position, below (Example: D11):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc3;
cout<<"Enter row number: ";
cin>>sr3;
}





system("PAUSE");
return EXIT_SUCCESS;}

void ticketchoices()
{cout<<"Press 1 to select first class."<<endl;
cout<<"Press 2 to select business class."<<endl;
cout<<"Press 3 to select economy class."<<endl;
return;}

void displaychartfirst(char firstclass[2][6], int ticketnumselection)
{
int r=0,c=0;
if(ticketnumselection==1)
 {cout<<"       A  B  C  D  E  F"<<endl<<endl;
  for(r=0;r<2;++r)
   {  if(r>=1)
      {cout<<endl;}
   cout<<"Row "<<r+1<<"  ";
    for(c=0;c<6;++c)
     {cout<<firstclass[r][c]<<"  ";}}}
     cout<<endl;
     return;}

void displaychartbus(char busiclass[5][6],int ticketnumselection)
{
int r=0,c=0;
if(ticketnumselection==2)
 {cout<<"       A  B  C  D  E  F"<<endl<<endl;
  for(r=0;r<5;++r)
   { if(r>=1)
     {cout<<endl;}
   cout<<"Row "<<2+r+1<<"  ";
    for(c=0;c<6;++c)
     {cout<<busiclass[r][c]<<"  ";}}}
     cout<<endl;
     return;}

void displaycharteco(char ecoclass[6][6],int ticketnumselection)
{
int r=0,c=0;
if(ticketnumselection==3)
 {cout<<"       A  B  C  D  E  F"<<endl<<endl;
  for(r=0;r<6;++r)
   {  if(r>=1)
      {cout<<endl;}
   cout<<"Row "<<7+r+1<<"  ";
    for(c=0;c<6;++c)
     {cout<<ecoclass[r][c]<<"  ";}}}
     cout<<endl;
     return;}
you don't have a cin for it its kind of hard to extract an int without it
To be honest, the way you format your code is kind of hard to read. And bunching up your block close braces (}}}) can be a little error prone when it comes to negotiating nested if/else blocks.
Last edited on
@ Aramil: Yes, I do:

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
int sr1,sc1,sr2,sc2,sr3,sc3;
if(ticketnumselection==1)
{
cout<<"Please, enter your seat position, below (Example: A2):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc1;
}
if(ticketnumselection==1)
{
cout<<"Enter row number: ";
cin>>sr1;
}
 
if(ticketnumselection==2)
{
cout<<"Please, enter your seat position, below (Example: C3):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc2;
cout<<"Enter row number: ";
cin>>sr2;
}

if(ticketnumselection==3)
{
cout<<"Please, enter your seat position, below (Example: D11):"<<endl;
cout<<"Enter seat letter: ";
cin>>sc3;
cout<<"Enter row number: ";
cin>>sr3;
}


@Galik: I apologize.
i know i realized that after i posted and didnt have time to edit it
Any idea why my program is doing this (not accepted data from the keyboard for the second prompt)?
Topic archived. No new replies allowed.